Some questions about GetDIBits and SetDIBits functions
Why do these functions have separate arguments for hDC and Bitmap handles? Since the Bitmap is going to be selected into the DC, why don't these functions just use the DC's handle (the hDC) for getting at the image data. Why do these functions require 2 separate handles? And what information about the image do they get from each of these objects (the DC, and the Bitmap)? Furthermore, why do these functions then further also require a BitmapInfoHeader structure to be passed to them? Don't these functions get all the info they need about the picture in question from the Bitmap and DC objects, who's handles you pass to these functions?
Since you pass separate DC and Bitmap handles to the GetDIBits and SetDIBits functions, does the Bitmap not need to be selected into the DC, when using these functions? Can I just use GetDC(0) to get the main screen's DC, or CreateCompatibleDC(0) to create a temporary DC, to act as a kind of "dummy" DC for filling the hDC argument in the GetDIBits or SetDIBits functions, while the actual Bitmap (who's bits I want to Get or Set) is on its own (not selected into the DC)?
Re: Some questions about GetDIBits and SetDIBits functions
Is nobody here familiar enough with the GetDIBits and SetDIBits functions to be able to answer these questions?
Re: Some questions about GetDIBits and SetDIBits functions
i do think that the DC is used to convert the data of the Input bitmap and the BitmapInfoHeader defines the Output Format.
i guess the api selects the Bitmap into the dc, extracts and converts the Bitmap data by using the dc. The target format is defined by the BmpHeader.
and yes, you can just pass GetDc(0) for the DC that should work.
Re: Some questions about GetDIBits and SetDIBits functions
Quote:
Originally Posted by
digitalShaman
i do think that the DC is used to convert the data of the Input bitmap and the BitmapInfoHeader defines the Output Format.
i guess the api selects the Bitmap into the dc, extracts and converts the Bitmap data by using the dc. The target format is defined by the BmpHeader.
and yes, you can just pass GetDc(0) for the DC that should work.
I'm pretty sure that with a call to GetDC(0) you need an equivalent call to ReleaseDC(0,hDC). This means you need an hDC variable to store the hDC returned by the GetDC(0) function call, so it can later be used in conjunction with ReleaseDC(0,hDC). Otherwise there's stuff that's left not properly cleaned up in your project's memory space. So you don't want to use GetDC(0) directly as a passed parameter in the call to GetDIBits or SetDIBits).
Re: Some questions about GetDIBits and SetDIBits functions
you need releasedc. i rather meant that the handle returned by getdc(0) can be used as parameter to getdibits
Re: Some questions about GetDIBits and SetDIBits functions
Regarding your initial post, the hDC and bitmap header structures can be used for options.
hDC. This has information relative to ICM (color management), along with type of DC: class, memory, etc
BMP structures: this can be used to convert passed bitmap to/from different bit depths