-
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.
-
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.
-
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."
-
In C++:
Code:
HBITMAP hBitmap = static_cast<HBITMAP>(LoadImage(...));
In C:
Code:
HBITMAP hBitmap = (HBITMAP)LoadImage(...);