Advertisement

Diplaying a bitmap in windows

Started by January 19, 2000 07:41 PM
3 comments, last by node_5r 25 years, 1 month 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
Are you referring to Windows the operating system or like an actual window? Also, are you talking about using DirectX or MFC or what?
Advertisement
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