views:

1112

answers:

2
A: 

Do you know the format of the image data the BYTE pointer points at? For Image to be able to construct itself from a stream, the data must be in one of the supported standard image formats (GIF, PNG, JPEG etc).

The IStream interface looks to be simple enough to implement on your own, if there's no suitable "memory stream" or similiar.

unwind
+2  A: 

CreateStreamOnHGlobal will take an HGLOBAL and give you an IStream pointer. You'll need to allocate enough memory with GlobalAlloc, and then copy your BYTE array into the HGLOBAL.

If you know that the image data you've got is a GDI DIB, you can use GdipCreateBitmapFromGdiDib or the corresponding Bitmap::Bitmap constructor.

Roger Lipscombe
Many thanks Roge, I opened the image successfully, and I find I was wrong the BYTE is not a Dib but a normal binary image file stream in JPG format. I opened it directly by FreeImage. Thanks.