Thread: Bitmap

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    207

    Bitmap

    I'm trying to display a bitmap image on the client area of my window.

    I'm using Charles Petzold's book "Programming Windows" but I can't seem to find how to do this?! I've looked in Chapter 14 and found a program that puts an icon file on your client area but that's not what I want.

    I'm using MSVC++ ver 6.0 and Windows XP home edition.

    I've added the image to my resource file and added it to my header file as well. I was just wondering how to draw it?! I can't believe I can't find it in my book!?

    I was thinking you had to declare it in the window class declaration but I'm not sure where/how to put it.

    Is it possible to draw the bitmap "on the fly" (ie: AFTER declaration of the window class)?

    mw
    Blucast Corporation

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    As you are using VC6 (pre .NET version) make sure you read the GDI leaks bit at the 'displaying bitmaps' link.

    In the 'bitmap sample' link the code contains a GDI leak for pre .NET versions of MSVC (ie VC6).

    .NET version make GDI objects in a default state that are cleaned up by the system when out of scope.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Dev-Cpp winanim example is good...

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    207
    When I try to load my bitmap as a resource it seems to be successful but it says that it can't display it. I think it's because it has too many colors to display or something like that.

    However, when I try to load it with my code it's unsuccessful.

    If MSVC++ 6.0 can't display the bitmap resource, would that prevent it the LoadBitmap command from working?

    mw
    Blucast Corporation

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    207
    Ok, I found a book at Border's (for $75 freaking bucks that I don't have) that said LoadBitmap doesn't work if your bitmap is more than 256 colors. Or something like that. I can't remember exactly...

    In other words: if your bitmap was created on or after the time that Windows was first created then LoadBitmap won't work.

    The book suggested using LoadResource for your bitmap instead.

    I'm not sure how many colors my bitmap uses but how do I tell? Does the number of actual colors used dictate the number of colors it CAN use? (ie: even if I don't use 2 million colors in my bitmap, can it still be a true-color bitmap?)

    Am I barking up the wrong tree?

    mw
    Blucast Corporation

  7. #7
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    I think LoadImage can load bitmap resources that have 256 colors.

    Code:
    bitmap = (HBITMAP)LoadImage(GetModuleHandle(0),
                                MAKEINTRESOURCE(ID_MYBITMAP),
                                IMAGE_BITMAP,
                                0,0,0);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 01:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM