window_handle
window_handle

Reputation: 119

Unable to figure out problem with BitBlt in win32

I am new to windows programming and stuck with legacy code of software and having difficulty in figuring out the cause. The problem at hand is I have a SourceHDC and I am dumping it onto ScreenDC(HWND) and to memory DC. The screenDC behaves strangely in the sense that when application is sending my SourceHDC as black(I dumped it) it doesn't blit any thing black on ScreenDC however on my memoryDC I get black rectangle.

The BitBlt operation being passed is SRC_COPY

What could be the cause here? How to debug this further. Please advice. Could this be because of alpha. If yes how do i ensure alpha copying in my memoryDC?

Edit

//mHDC is ScreenDC

//create compatible DC from mDC
HBITMAP SCREENBITMAP = CreateCompatibleBitmap(mHDC, ScreenWidth, ScreenHeight);
HDC SCREEN = CreateCompatibleDC(mHDC);
SelectObject(SCREEN, SCREENBITMAP);

//Blitting back to back and then dumping
BitBlt(mHDC, realDstRect.left, realDstRect.top, dstWidth, dstHeight, srcDC, realSrcRect.left, realSrcRect.top, SRCCOPY);
BitBlt(SCREEN, realDstRect.left, realDstRect.top, dstWidth, dstHeight, srcDC, realSrcRect.left, realSrcRect.top, SRCCOPY);

Attached are the dumps. I noticed one problem the first image (SrcDC) appears black on my screen and here its white

SrcDC

Src DC

ScreenDC

ScreenDC

MemoryDC

Memory DC

Upvotes: 2

Views: 148

Answers (0)

Related Questions