Need device independent bitmap bits

320 Views Asked by At

I'm building a dll in C++ to be imported into a VB project. The dll exposes a function that will extract the preview image of a specified document through the Win Shell, and then writes it into a buffer to be used by the VB app.

So far, I'm able to get the HBITMAP handle without issue. I was also able to extract the bitmap data using the GetBitmapBits function. However, this will not work as the object that requires the bit data needs it to be in a device independent format.

I've read that GetDiBits is the function to use for this purpose, but I'm having a hard time figuring out how to call the function successfully.

What device context should I be using? Also, how can I ensure that it writes out the data in device independent format?

Thanks in advance.

1

There are 1 best solutions below

1
On

If your HBITMAP references a device dependent bitmap, and you need device independent bits, you have to convert them. Try creating a CImage and call the BitBlt method to put device independent bits in it.