Showing Bitmap Byte Array in a picture Box

  • Thread starter Thread starter Alex Feinman [MVP]
  • Start date Start date
It begs the question of how are you getting the byte array, but if it's
truly a byte stream, including the actual bitmap header, you can create a
Bitmap from the stream and then paint it to the pictureBox.

-Chris
 
I am getting a bit map byte array from a digital camera and I would like to
show it on a picture box control. Is it possible to do this?
 
Thanks Alex,

That's what exactly I wanted and now it works fine but a problem.

The image appears upside down! I tried reversing the byte array and it was
OK but slow.

Is this due to some setting in the CreateBitmap function or the camera sends
the data upside down?

Best Regards,
Y. Sivaram
 
Modify the code to make the height in the BITMAPINFOHEADER negative:

bi.biXPelsPerMeter = 0xb12;
bi.biYPelsPerMeter = 0xb12;

bi.biHeight = - bi.biHeight; // If the height is negative, the bitmap
orientation will be reversed

byte[] hdr = GetBytes(bi);
 
Alex,

Thanks. It worked fine!

Best Regards,
Y. Sivaram

Alex Feinman said:
Modify the code to make the height in the BITMAPINFOHEADER negative:

bi.biXPelsPerMeter = 0xb12;
bi.biYPelsPerMeter = 0xb12;

bi.biHeight = - bi.biHeight; // If the height is negative, the bitmap
orientation will be reversed

byte[] hdr = GetBytes(bi);


Y. Sivaram said:
Thanks Alex,

That's what exactly I wanted and now it works fine but a problem.

The image appears upside down! I tried reversing the byte array and it was
OK but slow.

Is this due to some setting in the CreateBitmap function or the camera sends
the data upside down?

Best Regards,
Y. Sivaram
 
Back
Top