What is HDC for GetDIBits?

I used GetDIBits to get bitmap data from the context of a screen-compatible DIB in a specific format. I got the impression that DC is only needed for synthesizing a color table when the original bitmap is 8 bits per pixel or less. Since my original bitmap was a full 32-bit color image, and it was a one-time program, and I did not have a DC screen, I set the HDC parameter to NULL. This did not work. As soon as I grabbed the DC screen and passed it, it started to work.

This made me wonder why GetDIBits requires a device context. What is it used for?

+4
source share
1 answer

IN:

 int SetDIBits( __in HDC hdc, __in HBITMAP hbmp, __in UINT uStartScan, __in UINT cScanLines, __in const VOID *lpvBits, __in const BITMAPINFO *lpbmi, __in UINT fuColorUse ); 

The second argument to hbmp is a device-dependent bitmap that will be modified using color information from a device-independent bitmap. hdc is the device context handle on which this (device-dependent) bitmap depends. When the call is made, Windows uses the information from this device context to decide how to perform the conversion.

0
source

All Articles