Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get the image reversed in C#

Tags:

c#

bitmap

flip

this is my code to turn a byte[] array into an image

unsafe
{
  //convert the UInt32[] into byte array and then assign the pointer to it
  fixed (byte* ptr = Misc.ConvertFromUInt32Array(image)) 
  {
    Bitmap bmp = new Bitmap(200,64,800,
      PixelFormat.Format32bppRgb,
      new IntPtr(ptr));
    bmp.Save("test.bmp");
  }
}

And I get this:

alt text http:////img11.imageshack.us/img11/4853/testacr.png

Where's the problem in the code,why that happens? How to flip it back to normal?

like image 257
Ivan Prodanov Avatar asked Dec 29 '25 11:12

Ivan Prodanov


1 Answers

   bmp.RotateFlip(RotateFlipType.Rotate180FlipX);

Fixed the problem :)

like image 180
Ivan Prodanov Avatar answered Dec 31 '25 01:12

Ivan Prodanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!