Results 1 to 6 of 6

Thread: Some questions about GetDIBits and SetDIBits functions

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    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)?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    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?

  3. #3
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    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.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: Some questions about GetDIBits and SetDIBits functions

    Quote Originally Posted by digitalShaman View Post
    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).

  5. #5
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    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

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width