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.

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 on other sites
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 on other sites
What are mapping modes?

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 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.

1. 1
Rutin
68
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 21
• 10
• 33
• Forum Statistics

• Total Topics
633438
• Total Posts
3011880
• Who's Online (See full list)

There are no registered users currently online

×