|
-
Feb 18th, 2002, 12:12 PM
#1
Thread Starter
Frenzied Member
displaying graphic
I know how to display a graphic on my window using a resource file, but now I want to display a bitmap from the hard drive...like non-resource. Im sure I could find an API for it but I thought I'd ask you guys first before waisting hours and hours on msdn
-
Feb 18th, 2002, 12:24 PM
#2
Monday Morning Lunatic
You can use LoadImage :-)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 18th, 2002, 12:29 PM
#3
Thread Starter
Frenzied Member
heh this is why I asked...I'd find that within about 6 hours on msdn 
thanks mike I'll give that one a shot
-
Feb 18th, 2002, 12:34 PM
#4
Thread Starter
Frenzied Member
msdn is so damned confusing! if you have a few minutes to spair could you write an example line?
-
Feb 18th, 2002, 12:38 PM
#5
Monday Morning Lunatic
I have approximately 0 minutes spare, since I'm at work and then have to get straight back to do a concert *sigh*.
The perils of being musical
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 18th, 2002, 12:47 PM
#6
Thread Starter
Frenzied Member
Im lucky if I can stay with the beat of the music playing on my computer thanks and have fun!
-
Feb 18th, 2002, 05:24 PM
#7
I have time to spare:
Load a bmp file to a bitmap handle:
Code:
HBITMAP hBmp = LoadImage(NULL, "myfile.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
Then you can draw the bitmap using DrawState, or you can use it as a brush pattern or insert it into a device context...
If you have
#define STRICT
before you include windows.h you'll have to add
(HBITMAP)
before the LoadImage call.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 18th, 2002, 06:23 PM
#8
Thread Starter
Frenzied Member
I got an error:
initializing' : cannot convert from 'void *' to 'struct HBITMAP__ *'
and how would I put this on the screen? could BitBlt do it? I haven't been getting BitBlt to work
-
Feb 19th, 2002, 08:53 AM
#9
I told you. If you have #define STRICT before including windows.h (or if you are using MFC), you need to write it like this:
HBITMAP hBmp = (HBITMAP)LoadImage(...
Write it like this even if you don't have the define, because it doesn't hurt and will correct the failure.
I told you the second thing too.
a) DrawState
Code:
DrawState(hdc, NULL, NULL, MAKELONG(hBmp, 0), 0, x, y, 0, 0, DST_BITMAP | DSS_NORMAL);
b) select it into a dc, you can then use BitBlt
Code:
// get width and height of bitmap for blt operation
BITMAP bmp;
GetObject((HGDIOBJ)hBmp, sizeof(BITMAP), &bmp);
HDC hMemDC = CreateCompatibleDC(hdc);
SelectObject(hMemDC, (HGDIOBJ)hBmp);
BitBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hMemDC, 0, 0, SRCCOPY);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 19th, 2002, 11:53 AM
#10
Thread Starter
Frenzied Member
perfect! thanks cornedbee!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|