OK all you bug hunters, here's the early release of the image library. Let it unzip to your MASM32 directory and then you can play with the pieces. It includes a sample application (literally stolen from Icz's tuts) (I think it's #5) and the libs themselves.
First, the function protos:
To use the functions of the lib, first reference the lib:
***READ THIS NEXT PART***
***READ THIS NEXT PART***
***READ THIS NEXT PART***
***READ THIS NEXT PART***
Define the filepath you wish to load:
***NOTE IT SAID FILEPATH***
***THAT MEANS WHAT IT SAYS***
*** FILE AND PATH, FILE ALONE WILL FAIL***
(emphasis added out of sheer desperation)
Files may be added in several ways (two of these lines should be commented out) in the WM_CREATE message handler
Inside the WM_PAINT message handler, copy the bitmap to the screen.
Finally, don't forget a resource file:
Stir well, then bake at 350? for two hours. Server while still hot.
I hope you find this usefull. Your comments are appreciated.
(the download has been corrected for hutch's comment) (I *hope!*)
(Download also corrected for Worrier King's reported problem concerning buffer size) (see later concerning MultiByteToWideChar)
First, the function protos:
BitmapFromFile PROTO pszFileName:DWORD
BitmapFromMemory PROTO pHeap:DWORD, dwSize:DWORD
BitmapFromResource PROTO hModule:DWORD, lpName:DWORD
To use the functions of the lib, first reference the lib:
include image.inc
includelib image.lib
***READ THIS NEXT PART***
***READ THIS NEXT PART***
***READ THIS NEXT PART***
***READ THIS NEXT PART***
Define the filepath you wish to load:
szFile BYTE "C:\masm32\ImageLib\homer.jpg", 0
***NOTE IT SAID FILEPATH***
***THAT MEANS WHAT IT SAYS***
*** FILE AND PATH, FILE ALONE WILL FAIL***
(emphasis added out of sheer desperation)
Files may be added in several ways (two of these lines should be commented out) in the WM_CREATE message handler
invoke BitmapFromFile, ADDR szFile
invoke BitmapFromResource, hInstance, 2002
invoke BitmapFromResource, hInstance, 2001
Inside the WM_PAINT message handler, copy the bitmap to the screen.
invoke CreateCompatibleDC, hdc
mov tempDC, eax
invoke SelectObject, tempDC, hBmp
mov htbmp, eax
invoke BitBlt, hdc, 0,0,rect.right,rect.bottom, tempDC, 0, 0, SRCCOPY
invoke SelectObject, tempDC, htbmp
invoke DeleteDC, tempDC
Finally, don't forget a resource file:
2001 BITMAP DISCARDABLE "homer.bmp"
2002 IMAGE DISCARDABLE "homer.gif"
Stir well, then bake at 350? for two hours. Server while still hot.
I hope you find this usefull. Your comments are appreciated.
(the download has been corrected for hutch's comment) (I *hope!*)
(Download also corrected for Worrier King's reported problem concerning buffer size) (see later concerning MultiByteToWideChar)
Ernie,
I unzipped the example and tested the three functions.
BitmapFromFile failed with return value 0
BitmapFromResource worked fine with jpg, gif and bmp.
Compliments, this is good stuff.
Regards,
hutch@movsd.com
I unzipped the example and tested the three functions.
.ELSEIF uMsg==WM_CREATE
; invoke BitmapFromFile, ADDR szFile
; invoke BitmapFromResource, hInstance, 2002
invoke BitmapFromResource, hInstance, 2001
mov hBmp, eax
ShowReturn 0, eax
BitmapFromFile failed with return value 0
BitmapFromResource worked fine with jpg, gif and bmp.
Compliments, this is good stuff.
Regards,
hutch@movsd.com
Thought I would try a test piece using a larger JPG image. This is good technology as it allows JPG image size storage in resources that can be large images when loaded as bitmaps.
I used a badly underexposed image of my old car after tweaking it in Picture Publisher and saving it as a jpeg file.
Regards,
hutch@movsd.com
I used a badly underexposed image of my old car after tweaking it in Picture Publisher and saving it as a jpeg file.
Regards,
hutch@movsd.com
Hutch,
First off, actually downloading my own package and installing it led me to duplication your problem loading the image from a file.
Seems I have the wrong path hard coded in for szFileName. Just adjust that string to your actual path and it will work. (Hey, thats why we call em beta versions). The above download has been corrected.
Thanks for your compliments, that is a badge of honor.
First off, actually downloading my own package and installing it led me to duplication your problem loading the image from a file.
Seems I have the wrong path hard coded in for szFileName. Just adjust that string to your actual path and it will work. (Hey, thats why we call em beta versions). The above download has been corrected.
Thanks for your compliments, that is a badge of honor.
Does the file name in BitmapFromFile need to be Unicode, and a full path?
Full path, yes. Unicode, no.
I felt sorry for you ASCII types and did the translation to Unicode inside the lib function. ;-)
Check the sample program and the help doc too.
I felt sorry for you ASCII types and did the translation to Unicode inside the lib function. ;-)
Check the sample program and the help doc too.
Does this lib work on all Windows versions ?
Looks nice :alright:
Looks nice :alright:
I applause !
Very nice and useful !
Thanks Ernie !
Very nice and useful !
Thanks Ernie !
Thanks Jimmy and Readiosys
These lib functions depend on two API functions, OleLoadPicture and OleLoadPicturePath. These require the following versions:
Windows NT/2000/XP: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
PS: My moving GIF control is humming along. I just completed a procedure that returns any single image (as a bitmap of course) from a multiple image .GIF stream.
Now gotta plan out the next step, probably a custom window control that updates itself witn no other program intervention.
These lib functions depend on two API functions, OleLoadPicture and OleLoadPicturePath. These require the following versions:
Windows NT/2000/XP: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
PS: My moving GIF control is humming along. I just completed a procedure that returns any single image (as a bitmap of course) from a multiple image .GIF stream.
Now gotta plan out the next step, probably a custom window control that updates itself witn no other program intervention.
i don't use php so can i get the zip file in another format ?
i don't find image.inc and image.lib in masm package i guess in php file.
i don't find image.inc and image.lib in masm package i guess in php file.
Just left click on the link. Don't right click/save as, that won't work.
i don't know what you mean i got the file but i don't know how to open it. what kind of editor ?
The file you have is not the archive. Go back to Ernie's message, and left click on the link there.
You can't save an attached file from this forum by right clicking and selecting "save as", which is what it looks like you did.
You can't save an attached file from this forum by right clicking and selecting "save as", which is what it looks like you did.
Actually - (I've been asking that question too once) - the attachment.php is the attachment... Just rename it to whatever.zip and it works...
Regards,
JimmyClif
Regards,
JimmyClif
Thanks a bunch Ernie. This'll save a lot of headaches for non-COMmies like me.
(edited cause I've been staring at this monitor for way too long and am no longer able to coherently type)
(edited cause I've been staring at this monitor for way too long and am no longer able to coherently type)
thank's Jimmy your method is working is it a kind of tricky of programming ? i guess not :)
Is paint.exe supposed to do something?
It opens a blank window, and I don't see a picture. But in the paint.asm file I see it calls your loadpicture routines in the WM_CREATE.
This is on Win XP.
It opens a blank window, and I don't see a picture. But in the paint.asm file I see it calls your loadpicture routines in the WM_CREATE.
This is on Win XP.
It's possible it doesn't work on WinXP. I don't have a copy to check it out on.
Anyone get it to work there?
Anyone get it to work there?
Woohoo
Just wanted to drop a line saying that after some minor changes (had to change 1 line of code) the image.lib did it's wonder already.. The Filesize got reduced from 3.8MB to an amazing 444KB.. Small is beautiful ;)
I'm never working with bmp's again.. (lol)
PS: It works like a charm on XP.
Just wanted to drop a line saying that after some minor changes (had to change 1 line of code) the image.lib did it's wonder already.. The Filesize got reduced from 3.8MB to an amazing 444KB.. Small is beautiful ;)
I'm never working with bmp's again.. (lol)
PS: It works like a charm on XP.
Yes paint.exe is supposed to show Ernie's Avatar..
As he put c:\masm32\image\homer.gif in the paint.asm you have
to either put homer into the above mentionned path or recompile
it with wherever you want the path to be...
As he put c:\masm32\image\homer.gif in the paint.asm you have
to either put homer into the above mentionned path or recompile
it with wherever you want the path to be...