Results 1 to 10 of 10

Thread: displaying graphic

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    msdn is so damned confusing! if you have a few minutes to spair could you write an example line?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Im lucky if I can stay with the beat of the music playing on my computer thanks and have fun!

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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
  •  



Click Here to Expand Forum to Full Width