I have a Bitmap image that i want to load dynamically. But I am unable to load it.
CBitmap bmp;
bmp.LoadBitmap("c:\\aeimg");
it does not seem to be working. Can someone please help me.
Thanks.
I have a Bitmap image that i want to load dynamically. But I am unable to load it.
CBitmap bmp;
bmp.LoadBitmap("c:\\aeimg");
it does not seem to be working. Can someone please help me.
Thanks.
CImage doesn't work with png last time I tried / checked. Have a look at CxImage - http://www.codeproject.com/KB/graphics/cximage.aspx .
According to CBitmap documentation:
LoadBitmap()
function takes resource identifier of the bitmap or resource id of the bitmap.You can't specify the path of the bitmap file.
E.g.
and make sure that resource.h does not have any entry of MYBMP otherwise during preprocessing its replaced by id and ultimately
LoadBitmap()
will fail since application can't locate the resource asFindResource()
fails.Now do this :
It will definitely load the bitmap.
You can also try something like this:
CBitmap
doesn't support directly reading from a .bmp file. You can instead make use ofCImage
class as suggested in other answers. You'll need to includeatlimage.h
in your code to makeCImage
work:Another way is to load the image using
LoadImage
Win32 API and then attachingCBitmap
to that:It could be as simple as you forgetting to escape the backslash. Instead of
use
Otherwise you're passing an invalid path to the LoadBitmap method.
To load a bitmap from a file, you want to use
LoadImage
with theLR_LOADFROMFILE
flag.