Sounds like the BITMAPFILEHEADER has been stripped from these DIBs, and
they start directly with the BITMAPINFO data (after the size DWORD).
If they might be different color depths, then you should read the data
into a BITMAPINFOHEADER structure to find the color depth, then go back
to the start and read it into a BITMAPINFO structure with the proper
palette length. When you've filled that up, the rest goes into a byte
array. You can now display it in a picturebox using SetDIBits() API
The picturebox must be _exactly_ the right size (not incl. borders),
with ScaleMode = pixel, and AutoRedraw should be true unless you want
to call SetDIBits() in every paint event.
Or you can write it out to disk and make a bmp file out of it by
stripping off that DWORD (four bytes) and replacing it with
Private Type BITMAPFILEHEADER '14 bytes
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
bfType = &H4D42
bfSize = the DWORD value + 14 (or 10? if the DWORD includes itself)
bfOffBits = 40
MS Dev MVP
Quote:> I want to display a preview image which is stored in an OLE2 file as
> DIB. I managed to get the DIB into an array, but I'm stuck now
> a picture box to display it. The problem is IMHO, that the DIB is
> stored not quite right. Supposedly a DIB should look like this: "BM",
> Header with size and eventually color palette, data.
> The application writes the DIB like this (from their help file):
> "DWORD (data size) followed by continues chunk of memory of that size
> (data). The data being read can be cast to LPBITMAPINFO which has
> information required to display the bitmap."
> VB's Picture Control or (when saved to a file) CorelPhotoPaint does
> not recognize the format.
> Anybody knowing what I have to do to display this DIB in VB?
> Marc Fiedler