I am trying to load bitmap data from a form into a bitmap structure so that i can write it to disk. I have successfully used the BitBlt call to copy the bitmap from the form to a Memory DC (using a compatible bitmap) and I have then ensured that the bitmap isn't currently selected into the memory DC (since i read that GetDIBits doesn't work if the bitmap is currently selected into any DC's).

I have setup the BitmapInfoHeader and BitmapInfo structures using an array of 256 RGBQUAD structures. And I have specified the biBitCount value in the bitmapinfoheader structure to be 8 (256 colours).

I have used GlobalAlloc and GlobalLock calls to successfully allocate memory for the bitmap bits. To calculate the amount of memory to allocate for the bitmap i have simply multiplied the imageheight by the imagewidth by the number of bits per pixel (and multiplied this by 8 to get the number of byted reqd.) ...Is this correct?

Sofar so good....now when i call the GetDIBits function it is failing. As far as i can tell I am doing everything correctly. I am running VB6 Professional, on Win98.

Any Ideas Appreciated...

Michael Yates