CBitmap (LoadBitmap is not working)
-
CBitmap mainBitmap; int nX1=mainBitmap.LoadBitmap("C:\\a.bmp"); "mainBitmap.LoadBitmap" return value is 0, means this function is not working well. Can u tell me from where i wrong.? if i use BitmapID like IDD_BITMAP, then LoadBitmap works well. but if i give the file name then it not works well. Actually i want to load a bitmap, but VC Bitmap drawing editor did not supports all the wanted color. so i made a bitmap in paint brush and now i want to load it. waiting for the answer
-
CBitmap mainBitmap; int nX1=mainBitmap.LoadBitmap("C:\\a.bmp"); "mainBitmap.LoadBitmap" return value is 0, means this function is not working well. Can u tell me from where i wrong.? if i use BitmapID like IDD_BITMAP, then LoadBitmap works well. but if i give the file name then it not works well. Actually i want to load a bitmap, but VC Bitmap drawing editor did not supports all the wanted color. so i made a bitmap in paint brush and now i want to load it. waiting for the answer
I assume you working in MFC. Her Loadbitmap is declared as follow... BOOL LoadBitmap( LPCTSTR lpszResourceName ); BOOL LoadBitmap( UINT nIDResource ); Both tis function asume a resource ID. This resource ID can be a textvalue or UINT value. To load a bitmap from a file you can just call Win32 LoadBitmap API function (or LoadImage). On success then you attach it to the the CBitamp object.
-
I assume you working in MFC. Her Loadbitmap is declared as follow... BOOL LoadBitmap( LPCTSTR lpszResourceName ); BOOL LoadBitmap( UINT nIDResource ); Both tis function asume a resource ID. This resource ID can be a textvalue or UINT value. To load a bitmap from a file you can just call Win32 LoadBitmap API function (or LoadImage). On success then you attach it to the the CBitamp object.
I have too checked what u say, but no progress HBITMAP hBitmap=LoadBitmap(AfxGetApp()->m_hInstance,"C:\\a.bmp"); int nX=GetLastError(); return value is 1814, means "The specified resource name cannot be found in the image file. " Although file is present at the required address. any help ?
-
I have too checked what u say, but no progress HBITMAP hBitmap=LoadBitmap(AfxGetApp()->m_hInstance,"C:\\a.bmp"); int nX=GetLastError(); return value is 1814, means "The specified resource name cannot be found in the image file. " Although file is present at the required address. any help ?
Try... HANDLE LoadImage( HINSTANCE hinst, // handle to instance LPCTSTR lpszName, // image to load UINT uType, // image type int cxDesired, // desired width int cyDesired, // desired height UINT fuLoad // load options ); and set the hinst to NULL and lpszName to the filname you load,uType to IMAGE_BITMAP, fuLoad to LR_LOADFROMFILE. For other parameter and options look it up in MSDN. On success attach it (cast from HANDLE to HBITMAP).
-
Try... HANDLE LoadImage( HINSTANCE hinst, // handle to instance LPCTSTR lpszName, // image to load UINT uType, // image type int cxDesired, // desired width int cyDesired, // desired height UINT fuLoad // load options ); and set the hinst to NULL and lpszName to the filname you load,uType to IMAGE_BITMAP, fuLoad to LR_LOADFROMFILE. For other parameter and options look it up in MSDN. On success attach it (cast from HANDLE to HBITMAP).
-
CBitmap mainBitmap; int nX1=mainBitmap.LoadBitmap("C:\\a.bmp"); "mainBitmap.LoadBitmap" return value is 0, means this function is not working well. Can u tell me from where i wrong.? if i use BitmapID like IDD_BITMAP, then LoadBitmap works well. but if i give the file name then it not works well. Actually i want to load a bitmap, but VC Bitmap drawing editor did not supports all the wanted color. so i made a bitmap in paint brush and now i want to load it. waiting for the answer
CBitmap::LoadBitmap() converts the bitmap to the screen's bit depth therefore if you use CBitmap::LoadBitmap() to load the bitmap, the colors will be reduced to the bit depth of the main screen and you won't be able to access the pixels directly. To avoid these problems, load the bitmap as a DIBSection instead and attach the DIBSection to the CBitmap.