I'm construct a bmp viewer,but it seems there is little problem
the whole source code is at the attahment zip
use LoadImage for a BMP file
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045%28v=vs.85%29.aspx
invoke LoadImage,0,offset OutputString,IMAGE_BITMAP,0,0,LR_LOADFROMFILE
i was using LoadImage to load the bmp from a file
i have found my misunderstanding
invoke LoadBmp,addr width1,addr height1,addr size1,ofn.lpstrFile
...
LoadBmp proc pwidth,pheight,psize,pszfile
mov eax,bmpinfo.biHeight
mov [pheight],eax
LoadBmp endp
the instruction
mov [pheight],eax
is actually mov [ebp+12],eax
but originally i think it's somthing like this
mov [addr height1],eax
so i lost my self after i called the function but found the value of width1 was not changed
are you using GoAsm ???
if you are using Masm...
mov pheight,eax
perhaps you are reading some [GoAsm] example code and assembling with Masm :P
thanks for the remind, i almost forget the convenient way :green2
no i'm reading a C++ example ,the convert between C++ and masm sometimes make difficulty
An easy way to do that is to compile the C++ to an object file and disassemble that. With GCC you can compile your code with g++ code.cpp -c code.o and peek at the assembly result with objdump -dCr -Mintel code.o.
I'm sure there are equivalents using Microsoft's compiler ;).
Quote from: nixeagle on May 01, 2012, 03:12:19 AM
An easy way to do that is to compile the C++ to an object file and disassemble that. With GCC you can compile your code with g++ code.cpp -c code.o and peek at the assembly result with objdump -dCr -Mintel code.o.
I'm sure there are equivalents using Microsoft's compiler ;).
good advice ! i will give a try :dance:
Quote from: dedndave on May 01, 2012, 03:01:04 AM
are you using GoAsm ???
if you are using Masm...
mov pheight,eax
perhaps you are reading some [GoAsm] example code and assembling with Masm :P
i recompile use
mov pwidth,eax
but it seems it has the same problem with
mov [pwidth],eax
ps: i'm using masm
to get the size of the image after loading, i use GetObject...
LOCAL bms:BITMAP
;
;
INVOKE LoadImage........
;
;
INVOKE GetObject,hBitmap,sizeof BITMAP,addr bms
mov ecx,bms.bmWidth
mov edx,bms.bmHeight
;BITMAP STRUCT
; bmType dd ?
; bmWidth dd ?
; bmHeight dd ?
; bmWidthBytes dd ?
; bmPlanes dw ?
; bmBitsPixel dw ?
; bmBits dd ?
to understand the problem you are having with pheight/pwidth, we would need to see more of the code :P
offhand, it sounds like pheight and pwidth may be pointers - not the variables, themselves - thus the 'p'
try this...
mov edx,pheight
mov [edx],eax
mov ebx,bmpinfo.biWidth
mov eax,pwidth
mov [eax],ebx
mov ebx,bmpinfo.biHeight
mov eax,pheight
mov [eax],ebx
mov ebx,bmpheader.bfSize
sub ebx,bmpheader.bfOffBits
mov eax,psize
mov [eax],ebx
it works!
:U
:bg