Advertisement Jump to content
Sign in to follow this  
Lord Maz

Stuck with bitmaps.

This topic is 4973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got some trouble with loading/drawing bitmaps. I want to create a button that loads image data from a buffer and displays it. Here's some working code:
bitmaps[index] = CreateBitmap(32, 32, 1, 32, data);

HDC hdcMem = CreateCompatibleDC(lpdis->hDC);
SelectObject(hdcMem, pToolPanel->GetBitmaps()[(s32)wParam]);

BitBlt(lpdis->hDC, destRect.left,, destRect.right - destRect.left, destRect.bottom -,	hdcMem, srcRect.left,, SRCCOPY)

Might've missed something, but it's not that important. I want to switch to using CreateCompatibleBitmap instead - MSDN recommended it and a friend with windows 2000 seems to have a problem with the current code. So, how the heck do i do the same thing (load bitmap data and then draw it) with CreateCompatibleBitmap? I couldn't figure it out with MSDN only, and googling for help didn't help me either... Any help is appreciated!

Share this post

Link to post
Share on other sites
When using CreateCompatibleBitmap() first make sure that the DC it is compatible with already has a bitmap with the appropriate color depth selected into it. This could be a DC from your window but not a memory DC that hasnt already had a bitmap selected into it (by default the bitmap in memory DCs is 1x1 monochrom).

After that the code should be the same as what you have.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!