Hi,
I have been trying to flip an image vertically before saving in disk in AVI format. I really dont know why i need to flip it first before saving, any idea?
To do this currently i am performing a simple algorithm... - public Bitmap RotateFlip(Bitmap source, RotateFlipType change)
-
{
-
Bitmap dest = new Bitmap(source.Size.Width, source.Size.Height);
-
int MaxWidthIndex = source.Size.Width - 1;
-
int MaxHeightIndex = source.Size.Height - 1;
-
-
for (int X = 0; X < source.Size.Width; X++)
-
{
-
for (int Y = 0; Y < source.Size.Height; Y++)
-
{
-
switch (change)
-
{
-
case RotateFlipType.RotateNoneFlipY:
-
dest.SetPixel(MaxWidthIndex - X, Y, source.GetPixel(MaxWidthIndex - X, MaxHeightIndex - Y));
-
break;
-
default:
-
throw new Exception("Not implemented");
-
}
-
}
-
}
-
-
return dest;
-
}
-
-
This works correctly but has severe performance bottleneck. I guess due to Set & Get pixel methods.
If you know a better approach and can share code with me, I will really appreciate.
Thanks,
Shailendra
6 4397 tlhintoq 3,525
Recognized Expert Specialist TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Hi,
Thanks for reply... answers to your questions...
Then why are you doing it?
Bcoz i have to. If i dont, when i play recorded video, i see vertically flipped images being displayed.
Excuse me? You're saving your bitmap as an avi? Why?
Sorry I made an ambiguous statement. What i meant is, i am getting images from a netwrok camera and i want to record it as video. so to record video i am using AVI library (found a wrapper on code project), which allow me to add images into a video stream. However it is required to perform a flip before saving an image (this is the part i am not sure about).
I hope i m clear this time :)
Thanks
Shailendra
GaryTexmo 1,501
Recognized Expert Top Contributor
I don't know of a faster way to do a image flip than to just parse through the data and change it around. The only way I could say to optimize it would be that you could remove the switch statement in your code. Maybe set up some variables depending on the value... - destImage.SetPixel((direction * x) + startX, (direction * y) + startY);
Where direction is 1 or -1 and startX/Y is 0 or the width/height accordingly.
There may be faster ways, but unfortunately I don't know them. Sorry!
Thank you very much Gary for suggesting improvement. I will try this one.
GaryTexmo 1,501
Recognized Expert Top Contributor
Hmm, additionally it seems there's a built-in method on the Image class. http://social.msdn.microsoft.com/For...d-6e7907fd5e16
I don't know if it's any faster or not though, worth a try? I can't help but wonder if you know about this though 'cause you're using the same terminology and the same enum. If it's a matter of having it on a Bitmap class vs. an Image class, I'm pretty sure you can load a bitmap into an Image and vice versa. Some googling might be in order there though.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Earle Oxner |
last post by:
We are developing an application on PocketPC2002 platform
and we are trying to make webservice calls using HTTPS.
HTTP works fine but HTTPS does not work. The same code
which doesn't work on PocketPC, works on the laptop
with .NET Framework. I was hoping you could help me with
answering some questions:
1. Does HTTPS work for the...
|
by: Asad Khan |
last post by:
Hi, I have Visual Studio 2002 Enterprise Architecture Edition. I was
wondering if anyone has any information on how I can develop applications
for .Net Compact Framework using this IDE. I've heard Visual Studio 2003
ships with the functionality for .Net Compact Framework development. But
right now I have Visual Studio 2002. Is there anything I...
|
by: RicercatoreSbadato |
last post by:
I have to flip vertically a Bitmap. Is it possible with GDI+ and C#?
|
by: b. hotting |
last post by:
Hi,
Is there a way to zoom in on an image in the PictureBox (on Compact
Framework)?
or to add scrollbars which means i would be able to pan/move my image within
the picturebox?
thanks,
bjorn
|
by: marco |
last post by:
I'm a newbie and i'm doing a little application in C# for a Pocket PC that
open image. I don't
understand what i've to do to have a zoom of an image...i don't know where's
the error. If anyone know a simple code tell me the url :O)
private void Zoom200_Click(object sender, System.EventArgs e)
{
| |
by: bob |
last post by:
Hi
Using 2003 - targeting the compact framework (c#), but would like to do most
development using the full.net (manually leaving out stuff not in the
compact framework).
Q. Trying to find a way of converting a project to have builds for both
compact and full. Project properties doesn't seem to help
Thanks
|
by: avi |
last post by:
Hello,
I am trying to vertically center text in a background image, I found a solution on this site that sets the line-height to the height of the background image. This works just fine, except when the text is too long that it wraps.
div.module h2{
width:178px;
width:"182px";
height:28px;
font-family:"Avenir Black", verdana, geneva,...
|
by: Francesco Moi |
last post by:
Hi.
I'd like to flip horizontally an image with JavaScript. Is it
possible? Thank you very much.
|
by: Greg |
last post by:
Hello all,
I am looking to download an image from a website from within a compact
framework pda app. I have tried everything I could find and thus I
turn to you. Any help or suggestions would be appreciated.
Thank you.
|
by: gangui |
last post by:
I need to use an image with opacity for my project, but
when I import this with the method bitmap, the image miss the opacity. Since the image is a circle, I also tried to draw the image with the methods FillEllipse and DrawEllipse, but as I am using the compact framework i can not change the opacity in rgb.
Does anyone know if i can create...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |