🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Diplaying a bitmap in windows

Started by
3 comments, last by node_5r 24 years, 5 months ago
hey all, I was wondering how i could display a bitmap in windows. If you could explane and show me some example code that would be great thanks! later node_5r
Advertisement
Are you referring to Windows the operating system or like an actual window? Also, are you talking about using DirectX or MFC or what?
one way:
make your bmp, load it into the VC++ (create a new resource file and import a bitmap)
then:

HBITMAP bmp1;
HDC dc1;
HDC primary;

bmp1 = LoadBitmap(MAKEINTRESOURCE(bmp res id here),CurrentAppInstance)
primary = GetDC(windowHWNDhere);
dc1 = CreateCompatibleDC(primary);
SelectObject(dc1,bmp1);
BitBlt(primary,x,y,width,height,dc1,sourcex,sourcey,SRCCOPY);

that''s it. you can also:

LoadBitmap("C:\blabl\blabla.bmp",instance);

so you don''t have to create any resources.

If you are using MFC, the process is very similar (use MSDN for the rest).

If you are doing DirectDraw:
using above code, load the bitmap, select it into a DC, BitBlt to an offscreen surface, then blit using ddraw to the primary surface. Tell me if you want code for that...

later
my, that is certainly a broad question
-werdup-
Hey all its me! Sorry about the question. I am using Borland C++. And What i want is to make a new window and inside the window would be a bitmap! hope this helps!

later node_5r

This topic is closed to new replies.

Advertisement