Displaying DIB's 
Author Message
 Displaying DIB's

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
function.

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
End Type

bfType = &H4D42
bfSize = the DWORD value + 14 (or 10? if the DWORD includes itself)
bfOffBits = 40

Jim Deutch
MS Dev MVP



Quote:
> I want to display a preview image which is stored in an OLE2 file as
a
> DIB. I managed to get the DIB into an array, but I'm stuck now
getting
> 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
all
> 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?

> Thanks,

> Marc Fiedler



Fri, 24 Aug 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Displaying DIB's

2. ASP Returning a DIB Image (I think) from SQL , Netscape doesn't display it

3. ASP Returning a DIB Image (I think) from SQL , Netscape doesn't display it

4. Displaying a DIB graphic in VB

5. Displaying DIB in PictureBox works but...

6. Creating and Displaying a DIB from a 640x480 Byte Array

7. DIB to DX8 Display

8. Get DIB Info from a Clipboard DIB

9. Displaying a DIB

10. Dll returns a Handle to a DIB how can I display in picture box

11. Advanced StrechBlt / DIB question (using vbAccelerator's cDIBSection class)

12. Fast DIB's

 

 
Powered by phpBB® Forum Software