Hey guys
Just wondering if anyone could give me an example of how to use the BitmapFrom* (e.g BitmapFromFile) methods?
I'm really looking for how to properly format the path string for BitmapFromFile. I can't seem to figure it out..and GetLastError wont tell me anything
Thanks
Not sure what BitmapFromFile is but I assume it's Ernie's IPicture loader so you should be able to just pass a fully qualified path to the procedure. I haven't really tried it for a long time, not using MASM and prefering to write my own routines but I never remembered any huge problems other than the free memory bug in the lib reported by f0dder though that was probably taken care of years ago. There should be an entry in the MASM32 help file about the proc.
BitmapFromFile is included in the masm32lib
Theres an entry in the help file, but it doesn't give a usage example.
The source code doesn't hint at it either
It's strange. When I try using the "exist" procedure, with the full path "C:\Chrome\Projects\Learning\NeHe.bmp" it says it exists. But BitmapFromFile says it doesnt. I'm confused
A look at the source shows the following...
BitmapFromFile PROC public pszFileName:DWORD
invoke MultiByteToWideChar, CP_ACP, 0, pszFileName, -1, pwszFileName, dwLength
invoke OleLoadPicturePath, pwszFileName, NULL, NULL, NULL, ADDR IID_IPicture, ADDR pPicture
OleLoadPicturePath (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/08bad900-815a-4b6d-b977-92d5fdd7d9e8.asp)
OleLoadPicturePath requires a UNICODE path to the file, MultiByteToWideChar will translate the ANSI path to UNICODE for you but there should be no problems as long as it finds the file. Why not inline the function directly and try to spot where your applicaiton is failing, the error returned should be ERROR_FILE_NOT_FOUND if there is a problem with the path as it is set explicitly on exit.
Note at MSDN about OleLoadPicturePath:
The stream must be in BMP (bitmap), JPEG, WMF (metafile), ICO (icon), or GIF format.
Donkey
You posted while I was writing this.
You do not need BitmapFromFile to load a bitmap, it is meant to translate other formats to bitmaps (JPG/GIF etc...) just use LoadImage for a normal bitmap file...
LoadImage (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/loadimage.asp)
There are two examples in the masm32 installation of how to load a bitmap using LoadImage as Donkey suggested. one is BCraven's Calender (sic) example and a better one is showdib in Exampl02.
Paul
thanks guys
sorry if i seemed terse. I was just frustrated and confused.
Hi Maeser,
Here is a set of examples using BmpFromFile , BmpFromMem , BmpFromRsrc There was a thread in Spook's forum fixing the bugs found in the image library.
Source codes assembled with December edition MASM32 version 9.00 BETA
[attachment deleted by admin]