flat assembler
Message board for the users of flat assembler.
Index
> Windows > [Bitmap]How to display a bitmap file? |
Author |
|
LiuGuoHua(Chinese) 24 Jan 2004, 12:52
I know how to display a bitmap picture resource .
but how to display a bitmap file on my window? Thx!~ |
|||
24 Jan 2004, 12:52 |
|
comrade 24 Jan 2004, 18:36
Use LoadImage instead of LoadBitmap
|
|||
24 Jan 2004, 18:36 |
|
Vortex 24 Jan 2004, 20:17
Hi LiuGuoHua,
For a real example, have a look at Iczelion's assembly tutorial #25 : http://spiff.tripnet.se/~iczelion/tut25.html _________________ Code it... That's all... |
|||
24 Jan 2004, 20:17 |
|
Vortex 28 Sep 2004, 18:02
Hi vbVeryBeginner,
First of all, it looks like that you forgot to put the parameter of GetModuleHandle, have a look at you source code: Code:
invoke GetModuleHandle,
It should be : Code: invoke GetModuleHandle,0 Second, what's the meaning of 300? Code: invoke LoadBitmap,[insH],300 It should be: Code: invoke LoadBitmap,[insH],1 The original resource script: Code: #define IDB_MAIN 1 IDB_MAIN BITMAP "tweety78.bmp" After correcting the source file, your code runs fine. _________________ Code it... That's all... |
|||
28 Sep 2004, 18:02 |
|
vbVeryBeginner 28 Sep 2004, 20:20
Quote:
oh man, this silly mistake cost me some hours Last edited by vbVeryBeginner on 28 Sep 2004, 20:33; edited 1 time in total |
|||
28 Sep 2004, 20:20 |
|
vbVeryBeginner 28 Sep 2004, 20:32
so,
Code:
invoke GetModuleHandle,
why this could be assembled without error? coz fasm should show error of lacking param instead of assemble it. |
|||
28 Sep 2004, 20:32 |
|
Tomasz Grysztar 28 Sep 2004, 21:24
use WIN32AXP.INC to perform parameter checking.
|
|||
28 Sep 2004, 21:24 |
|
JohnFound 28 Sep 2004, 23:01
vbVeryBeginner wrote: why this could be assembled without error? coz fasm should show error of lacking param instead of assemble it. Parameter checking often can stop you from using some good technicques, possible only in assembly language. For example it is very frequent case: We want to create some object to make several operations with it and then to destroy it. Typical case - brush or pen. So, where to save the handle, until we need it for passing as argument to the procedure that will destroy the object (DeleteObject for example)? We can use some of the persistent registers - esi, edi, ebx. Or some local variable. But why to waste registers or to create one-time-using local variables? Simply, we can use the technique I call "early parameter passing": Code: ; ebx - handle to the device context ; esi - pointer to the rectangle we want to draw invoke CreateSolidBrush, $123456 ; some strange color. push eax ; prepare arguments for DeleteObject invoke FillRect, ebx, esi, eax ; we just lost eax (brush handle) ; Here is the trick - we call DeleteObject without argument, ; because the handle of the object is already pushed in the stack invoke DeleteObject Another, more complex example: Code: invoke CreatePen, PS_SOLID, 0, $123456 invoke SelectObject, [.hdc], eax ; we lost the handle. ;SelectObject returns the previous pen handle. push eax invoke CreateSolidBrush, $654321 invoke SelectObject, [.hdc], eax push eax ; Draw operations. invoke MoveToEx........... invoke LineTo....... invoke Rectangle....... etc. ; Cleanup invoke SelectObject, [.hdc] ; the handle of the previous brush is in the stack invoke DeleteObject, eax ; we destroy the brush. invoke SelectObject, [.hdc] ; the handle of the previous pen is in the stack invoke DeleteObject, eax ; we destroy the pen Regards. |
|||
28 Sep 2004, 23:01 |
|
vbVeryBeginner 29 Sep 2004, 09:49
Code: ; Here is the trick - we call DeleteObject without argument, ; because the handle of the object is already pushed in the stack invoke DeleteObject yup, it is a nice trick thanks |
|||
29 Sep 2004, 09:49 |
|
i-don 30 Sep 2004, 17:47
Like LiuGuoHua, I would like to know how to open, load and display a bitmap file at run-time. Most of the post above described about using resource bitmap. I hope anyone has idea to help us know.
Thank in advance. i-don. |
|||
30 Sep 2004, 17:47 |
|
Vortex 30 Sep 2004, 18:54
_________________ Code it... That's all... |
|||
30 Sep 2004, 18:54 |
|
i-don 02 Oct 2004, 02:54
Hi Vortex,
Thanks it helps very much. ps - We should have a pinned thread that listing some working examples from each forum. It will save some energy to ask subjects that already has an answer. i-don. |
|||
02 Oct 2004, 02:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.