News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Example of the BitmapFrom* Methods

Started by Maeser, February 25, 2006, 10:37:59 PM

Previous topic - Next topic

Maeser

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

donkey

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.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Maeser

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

Maeser

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

donkey

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

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

Maeser

thanks guys

sorry if i seemed terse. I was just frustrated and confused.

Vortex

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]