Jump to content
  • Advertisement
Sign in to follow this  
cptrnet

Display an Image in GDI

This topic is 4844 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

Hi, I have a class that draws things in gdi, I have a buffer to which I draw to then I BitBlt it over to the main DC. Im having trouble displaying an image though and it seems sometimes to mess up my whole drawing area. tempbmp = (HBITMAP)LoadImage(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); thats hows i load the bitmap image. But Im not quite sure how to get it to display on the DC. I have this method but it doesnt seem to work. I dont even know if I am doing it right or not.
void IGraphics::DrawImage(HBITMAP bmp)
{
  //HDC bmp_dc = CreateCompatibleDC(m_MainDC);
  SelectObject(m_BackDC, bmp);
  //BitBlt(m_BackDC, 0, 0, 30, 30, bmp_dc, 0, 0, SRCCOPY);
}

Share this post


Link to post
Share on other sites
Advertisement
Haven't done GDI in a while, but that looks more or less right. Create a memory DC, select the bitmap into that DC (which doesn't look like what you're doing), then blit from that DC to the screen DC. Might want to make sure your mapping modes are correct.

Share this post


Link to post
Share on other sites
If you don't know what mapping modes are then it's not likely that they're the problem. As Cata mentioned your code is not right. If you want the bmp to end up on the screen then select it into bmp_dc and blt bmp_dc to m_MainDC.

Share this post


Link to post
Share on other sites
Well I am using a back buffer call m_BackDC, I want everything to be drawn to that the Ill copy that over to the Main DC. I have tried doing that but It messes up all my other stuff, such as I am printing the text Hello World, and Im drawing a Rectangle. What it does is it only paints 30x30 up in the left hand corner and everything else is clipped off.

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!