Jump to content
  • Advertisement
Sign in to follow this  
Lord Maz

Stuck with bitmaps.

This topic is 4821 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:
//init
bitmaps[index] = CreateBitmap(32, 32, 1, 32, data);

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

BitBlt(lpdis->hDC, destRect.left, destRect.top, destRect.right - destRect.left, destRect.bottom - destRect.top,	hdcMem, srcRect.left, srcRect.top, 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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!