Being looking for an example in vain to load an image (bmp or jpg) from a folder on c:drive... LoadImage() function loads from resources, which i'm not very clear about either.. Few lines of code would help!
thanx
Being looking for an example in vain to load an image (bmp or jpg) from a folder on c:drive... LoadImage() function loads from resources, which i'm not very clear about either.. Few lines of code would help!
thanx
Something like:
--Code:HANDLE h; h = LoadImage(NULL, // hInst TEXT("blah.jpg"), // lpszName IMAGE_BITMAP, // utype 0, 0, // cxDesired, cyDesired LR_DEFAULTCOLOR); if (!h) // Error. ...
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Hi Mats, this is what i got from MSDN
This doesn't match the example you gave, please correct me if am wrong...Code:HRESULT LoadImage(LPWSTR pszFileName, IUnknown *pDirectDraw, DDSURFACEDESC *pDDSurfaceDesc, GUID *pFormatID, REFIID riid, void **ppDXSurface );
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
When you copy the path provided to the start\run menu is the file opened without problems?
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
What vart means is that you copy the name of your file to the "Start->Run..." menu on Windows. You would have to edit out the \\ into \ to make it work, but it's a good way to determine that the file is actually there.
I find this a bit suspicious:
--Code:c:\\Quest Projects\\Visual Studio\\Resources\\Resources\\radar_bgrnd.bmp
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Yes, I was trying something out yesterday, and realized that this only works on images that are part of the executable. I ended up using an MFC CImage - but if you don't use MFC for other stuff, then that's no help.
I'm afraid, I don't actually know if Windows native API supports loading bitmaps from a file, and if so, what the API is.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
More patience and less haste required(read the docs with a little more care):
Change/OR the last parameter of LoadImage and you should be good to go.Originally Posted by msdn, LoadImage
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
moved the file to the c: drive, and changed the code with no avail...
Error Number is zero this time but LoadImgae still returns null. In fact, when i debug and use the watch window to check value in radarBmp , it saysCode:radarBmp = (HBITMAP)LoadImage( NULL, TEXT("c:\\radar_bgrnd.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);.. Why is it saying unused as if LoadImage() never assigned any value... Maybe the casting (HBITMAP) is not workingCode:0x00000000 {unused=???}
I don't know what is wrong, but I can eliminate the suspicion of "casting HANDLE to HBITMAP" from the candidates - that should not change the value of the handle, just it's type.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.