位图图像处理与masm32
Bitmap image processing with masm32
我正在使用 masm 32。我想处理位图图像。但我不知道如何获取图像或保存图像。
我不知道用 masm 处理图像。
任何信息都会帮助我。
谢谢
这可能会让您入门...这是加载位图中并将其显示在对话框中的基本代码。我不确定 'processing' 位图图像是什么意思,我怀疑您需要更复杂的东西。但是,这可能会让您入门...
.386
.model flat,stdcall
option casemap:none
includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib gdi32.lib
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
IDD_DIALOG equ 1000
IDC_BITMAP equ 100
IDM_MENU equ 10000
.const
ClassName db 'DLGCLASS',0
.data?
hInstance dd ?
CommandLine dd ?
hWnd dd ?
hBitmap dd ?
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
invoke InitCommonControls
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL rect:RECT
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
; Load up the bitmap
invoke LoadBitmap, hInstance, IDC_BITMAP
mov hBitmap, eax
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx, eax
shr edx, 16
.if lParam==0
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.endif
.else
.endif
.elseif eax==WM_PAINT
invoke BeginPaint, hWnd, addr ps
mov hdc, eax
invoke CreateCompatibleDC, hdc
mov hMemDC, eax
invoke SelectObject, hMemDC, hBitmap
invoke GetClientRect, hWnd, addr rect
invoke BitBlt, hdc, 10, 10, rect.right, rect.bottom, hMemDC, 0, 0, SRCAND
invoke DeleteDC, hMemDC
invoke EndPaint, hWnd, addr ps
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke DeleteObject, hBitmap
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
注意 LoadBitmap API 调用和 WM_PAINT 例程。
..忘记了 .rc 文件...
#define IDD_DIALOG 1000
#define IDC_BITMAP 100
IDC_BITMAP BITMAP DISCARDABLE "myfile.bmp"
我正在使用 masm 32。我想处理位图图像。但我不知道如何获取图像或保存图像。 我不知道用 masm 处理图像。 任何信息都会帮助我。 谢谢
这可能会让您入门...这是加载位图中并将其显示在对话框中的基本代码。我不确定 'processing' 位图图像是什么意思,我怀疑您需要更复杂的东西。但是,这可能会让您入门...
.386
.model flat,stdcall
option casemap:none
includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib gdi32.lib
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
IDD_DIALOG equ 1000
IDC_BITMAP equ 100
IDM_MENU equ 10000
.const
ClassName db 'DLGCLASS',0
.data?
hInstance dd ?
CommandLine dd ?
hWnd dd ?
hBitmap dd ?
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
invoke InitCommonControls
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL rect:RECT
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
; Load up the bitmap
invoke LoadBitmap, hInstance, IDC_BITMAP
mov hBitmap, eax
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx, eax
shr edx, 16
.if lParam==0
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.endif
.else
.endif
.elseif eax==WM_PAINT
invoke BeginPaint, hWnd, addr ps
mov hdc, eax
invoke CreateCompatibleDC, hdc
mov hMemDC, eax
invoke SelectObject, hMemDC, hBitmap
invoke GetClientRect, hWnd, addr rect
invoke BitBlt, hdc, 10, 10, rect.right, rect.bottom, hMemDC, 0, 0, SRCAND
invoke DeleteDC, hMemDC
invoke EndPaint, hWnd, addr ps
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke DeleteObject, hBitmap
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
注意 LoadBitmap API 调用和 WM_PAINT 例程。
..忘记了 .rc 文件...
#define IDD_DIALOG 1000
#define IDC_BITMAP 100
IDC_BITMAP BITMAP DISCARDABLE "myfile.bmp"