On retrieving bits from a device context

Posted on 2004-11-24
Last Modified: 2013-11-20
I have two bitmaps which are selected into memory device context's

I do an Alpha Blend:

AlphaBlend(dcComparisonMem, 0,0, m_Width, m_Height, dcImageMem, 0,0,m_Width, m_Height,m_bf);

I need to now pull the bits out of dcComparisonMem into a buffer:

BYTE* pData = new BYTE(3000000)

for further processing post alpha-blend (rather than immediately blitting it to the display)

I thought I had to  do something like this:

VOID *pbitsBW;      
HBITMAP hBlended = ::CreateDIBSection(dcComparisonMem, pbmInfo, DIB_RGB_COLORS, &pbitsBW, NULL, NULL);
int iGetCount = ::GetDIBits(dcComparisonMem, hBlended, 0, m_Height, pData, pbmInfo, DIB_RGB_COLORS);

but iGetCount is only then equal to 1000 and my pData buffer doesn't hold the right data.

How do I retrived the bits into pData out of the DC  to which the AlphaBlend method blended the two?


Question by:PMH4514
    1 Comment
    LVL 48

    Accepted Solution

    If memory bitmap is created using CreateDIBSection, use GetBitmapBits to extract bits from it.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Complete beginner needs help making a cron job 9 93
    maven archtype selection in eclipse 1 47
    Change to event 1 52
    Problem to event 3 29
    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now