The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Maeser on February 25, 2006, 10:37:59 PM

Title: Example of the BitmapFrom* Methods
Post by: Maeser on February 25, 2006, 10:37:59 PM
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
Title: Re: Example of the BitmapFrom* Methods
Post by: donkey on February 25, 2006, 10:46:14 PM
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.
Title: Re: Example of the BitmapFrom* Methods
Post by: Maeser on February 25, 2006, 10:50:19 PM
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
Title: Re: Example of the BitmapFrom* Methods
Post by: Maeser on February 25, 2006, 11:06:12 PM
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
Title: Re: Example of the BitmapFrom* Methods
Post by: donkey on February 25, 2006, 11:09:03 PM
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)
Title: Re: Example of the BitmapFrom* Methods
Post by: PBrennick on February 25, 2006, 11:27:39 PM
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
Title: Re: Example of the BitmapFrom* Methods
Post by: Maeser on February 26, 2006, 06:20:12 AM
thanks guys

sorry if i seemed terse. I was just frustrated and confused.
Title: Re: Example of the BitmapFrom* Methods
Post by: Vortex on February 26, 2006, 10:19:09 AM
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]