byte array to image

  • Thread starter Thread starter Joey Wu
  • Start date Start date
J

Joey Wu

Dear All

I got a byte array that return from ccd of my device.
It contain a capture image data.
I have to convert it to image type and show it on picturebox.
But, when I try to do this.

picturebox1.image = new bitmap(new memorystream(picByte))

I got a ArgumentException.
Please give me a hand and thanks a lot !!


Joey
 
The Bitmap class consrtuctor expects a formatted (vs. raw) stream. It should
contain the same data as a graphic file would, including a valid header. The
easiest way to create a Bitmap object from raw data is to build the
appropriate BITMAPFILEHEADER and BITMAPINFOHEADER around it. YOu can find a
sample here:
http://www.alexfeinman.com/download.asp?doc=OnTheFlyBitmap.zip
Of interest to you is a function CreateBitmap(int width, int height, byte[]
rawdata)
Its output can be fed to the Bitmap constructor
 
Back
Top