Diplaying a bitmap in windows
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement