News:

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

loading bitmap from a file

Started by cakesy, October 24, 2006, 01:23:45 PM

Previous topic - Next topic

cakesy

Hi,

  Does anybody have any code for loading a bitmap from a file. I am interested in loading the wallpaper into a file (I know how to find the wallpaper location) - and I have searched this forum with no luck.

  I am writing a virtual window program, which expands your desktop to 4 windows, and it displays a snapshot of the screen in a small window. I want to display the wallpaper as the background for the 3 empty windows, when the program starts.

John

trodon

hi, do you meed something like this?



[attachment deleted by admin]

Vortex

cakesy,

Have a look at the BitmapFromFile file function, a member of masm32.lib :

BitmapFromFile proc pszFileName:DWORD

Description
BitmapFromFile returns a bitmap handle from an image file.
An image may be in either .bmp, .gif, .jpg, or .wmf format

Parameters
    1. pszFileName pointer to the pathname of an image file

Return Value
The return value is a handle to a bitmap representation of the file compatible with the screen device context. If the function fails, the return value is NULL. To get extended error information, call GetLastError.

cakesy

Thanks for your replies,

trodon: No, I wanted something that would actually load the file into memory, and display it in a window.

Vortex: I will have a look at the masm32.lib. I am not using any libraries at the moment though, so would have liked to just have some code.

TNick

LoadImage doesn't work for you?

INVOKE  LoadImage,  NULL,ADDR PathNameOfFile,IMAGE_BITMAP,0,0,LR_LOADFROMFILE

Darrel

cakesy,

I would suggest following Vortex's advice. Or you can load the file into memory and use one of the CreateBitmap (CreateDIBitmap) functions to obtain a handle to a bitmap to be placed in whatever window you want.

Regards,

Darrel

Darrel

I believe you want the wallpaper as a background for your windows, therefore, read the file into memory then use CreateDIBitmap to create a bitmap object then use CreatePatternBrush to create a brush object then set this as your WNDCLASSEX.hbrBackground member.

Regards,

Darrel  :8)