Loading Bitmaps

This is a discussion on Loading Bitmaps within the Windows Programming forums, part of the Platform Specific Boards category; Guys, which is better ? LoadBitmap() or LoadImage(), i understand LoadImage has more options like specifying the width and height, ...

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80

    Loading Bitmaps

    Guys, which is better ? LoadBitmap() or LoadImage(), i understand LoadImage has more options like specifying the width and height, but how do i store it ?
    Code:
    HBITMAP image;
    image = LoadImage(0,MAKEINTRESOURCE(IDB_BITMAP),IMAGE_BITMAP,50,50,LR_VGACOLOR);
    but an error came out
    Code:
    G:\C++\Task\task.cpp(21) : error C2440: '=' : cannot convert from 'void *' to 'struct HBITMAP__ *'
            Conversion from 'void*' to pointer to non-'void' requires an explicit cast
    And am i using the right value LR_VGACOLOR for resource type.
    /* Have a nice day */

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Since you're using C++ you'll need to cast the return value from HANDLE to HBITMAP using static_cast or the c equivalent if you prefer.

    You probably want to use LR_CREATEDIBSECTION as the last parameter to LoadImage. Also you can use 0 for the desired with and height and it will use the actual width and height from resource.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    Can you give me an example ? "Since you're using C++ you'll need to cast the return value from HANDLE to HBITMAP using static_cast or the c equivalent if you prefer."
    /* Have a nice day */

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    In C++:

    Code:
    HBITMAP hBitmap = static_cast<HBITMAP>(LoadImage(...));
    In C:

    Code:
    HBITMAP hBitmap = (HBITMAP)LoadImage(...);
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Loading Bitmaps in Allegro
    By LiNeAr in forum Game Programming
    Replies: 1
    Last Post: 08-15-2005, 05:12 PM
  2. Loading bitmaps with createfile() +CreateDIBSection
    By Stevo in forum Windows Programming
    Replies: 7
    Last Post: 05-13-2004, 10:22 PM
  3. Loading bitmaps without win32
    By /Muad'Dib\ in forum C++ Programming
    Replies: 0
    Last Post: 04-05-2004, 03:47 PM
  4. Loading Bitmaps
    By Neandrake in forum Windows Programming
    Replies: 4
    Last Post: 12-17-2001, 01:50 AM
  5. loading Bitmaps
    By Stealth in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2001, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21