473,569 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flip image vertically in Compact Framework

4 New Member
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...

Expand|Select|Wrap|Line Numbers
  1.         public Bitmap RotateFlip(Bitmap source, RotateFlipType change)
  2.         {
  3.             Bitmap dest = new Bitmap(source.Size.Width, source.Size.Height);
  4.             int MaxWidthIndex = source.Size.Width - 1;
  5.             int MaxHeightIndex = source.Size.Height - 1;
  6.  
  7.             for (int X = 0; X < source.Size.Width; X++)
  8.             {
  9.                 for (int Y = 0; Y < source.Size.Height; Y++)
  10.                 {
  11.                     switch (change)
  12.                     {
  13.                         case RotateFlipType.RotateNoneFlipY:
  14.                             dest.SetPixel(MaxWidthIndex - X, Y, source.GetPixel(MaxWidthIndex - X, MaxHeightIndex - Y));
  15.                             break;
  16.                         default:
  17.                             throw new Exception("Not implemented");
  18.                     }
  19.                 }
  20.             }
  21.  
  22.             return dest;
  23.         }
  24.  
  25.  
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
Mar 2 '10 #1
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.
Mar 2 '10 #2
tlhintoq
3,525 Recognized Expert Specialist
I really dont know why i need to flip it first before saving
Then why are you doing it?

before saving in disk in AVI format.
Excuse me? You're saving your bitmap as an avi? Why?

http://msdn.microsoft.com/en-us/libr...0).aspx?ppud=4
Mar 2 '10 #3
shailendrab
4 New Member
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
Mar 8 '10 #4
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...

Expand|Select|Wrap|Line Numbers
  1. 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!
Mar 8 '10 #5
shailendrab
4 New Member
Thank you very much Gary for suggesting improvement. I will try this one.
Mar 8 '10 #6
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.
Mar 8 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2592
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...
1
2501
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...
2
3039
by: RicercatoreSbadato | last post by:
I have to flip vertically a Bitmap. Is it possible with GDI+ and C#?
0
1391
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
2
7463
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) {
5
3323
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
4
4428
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,...
6
15726
by: Francesco Moi | last post by:
Hi. I'd like to flip horizontally an image with JavaScript. Is it possible? Thank you very much.
3
2617
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.
1
1704
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...
0
7697
marktang
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...
0
7612
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...
0
7924
Oralloy
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. ...
0
8120
jinu1996
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
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
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.