Win32汇编绘图
程序代码:
.386 .model flat,stdcall option casemap:none include gdi32.inc include user32.inc include windows.inc include kernel32.inc includelib gdi32.lib includelib user32.lib includelib kernel32.lib IDB_BUTTON1 equ 1 .data AppName db 'Win32',0 WinClass db 'WndClass',0 ExitAsk db 'Are you sure ?',0 Text db 'Hallo World !',0 WndClass2 db 'WndClass2',0 WClass db 'WindowClass',0 WName db 'Window',0 Button db 'Button',0 ButName db "退出",0 .data? hInstance HINSTANCE ? CommandLine LPSTR ? hwnd HWND ? fhWnd HINSTANCE ? hBut1 HINSTANCE ? utime1 dq ? utime2 dq ? ThreadId dd ? WinMain proto hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD PaintThread proto .code start : invoke GetModuleHandle,NULL mov hInstance,eax invoke GetCommandLine 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,NULL push hInstance pop wc.hInstance mov wc.hbrBackground,COLOR_WINDOW+1 mov wc.lpszMenuName,NULL mov wc.lpszClassName,OFFSET WinClass 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 CreateWindowEx,WS_EX_CLIENTEDGE,addr WinClass,addr AppName,WS_OVERLAPPEDWINDOW,10,10,1000,728,NULL,NULL,hInstance,NULL mov hwnd,eax invoke ShowWindow,hwnd,SW_SHOWNORMAL invoke UpdateWindow,hwnd .while TRUE invoke GetMessage,addr msg,NULL,0,0 .break .if eax == 0 invoke TranslateMessage,addr msg invoke DispatchMessage,addr msg .endw ret WinMain endp WndProc proc hWind:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM local ps:PAINTSTRUCT local rect:RECT local hDc .if uMsg == WM_CLOSE invoke MessageBox,hWind,addr ExitAsk,addr AppName,MB_OKCANCEL .if eax==IDOK invoke DestroyWindow,hWind invoke PostQuitMessage,NULL .endif .elseif uMsg == WM_PAINT invoke BeginPaint,hwnd,addr ps mov hDc,eax invoke GetClientRect,hwnd,addr rect invoke DrawText,hDc,addr utime1,-1,addr rect,DT_SINGLELINE or DT_VCENTER or DT_CENTER invoke EndPaint,hwnd,addr ps .elseif uMsg == WM_CHAR .if wParam =='P' invoke CreateThread,NULL,0,offset PaintThread,NULL,NULL,addr ThreadId .endif .else invoke DefWindowProc,hWind,uMsg,wParam,lParam ret .endif xor eax,eax ret WndProc endp PaintThread proc local hDcw pushad invoke GetDC,hwnd mov hDcw,eax mov eax,0 mov edx,975 mov ecx,720 push eax push edx push ecx invoke QueryPerformanceCounter,addr utime1 pop ecx pop edx pop eax lp1: push eax push edx push ecx push eax mov eax,950 sub eax,edx mov edx,eax mov eax,700 sub eax,ecx mov ecx,eax pop eax invoke SetPixelV,hDcw,edx,ecx,eax .if eax == -1 invoke MessageBox,NULL,addr AppName,addr AppName,MB_OK ret .endif pop ecx pop edx pop eax add eax,36 dec edx cmp edx,0 jnz lp1 mov edx,950 dec ecx cmp ecx,0 jnz lp1 invoke QueryPerformanceCounter,addr utime2 mov eax,DWORD PTR utime2 mov edx,DWORD PTR utime2+4 sub eax,DWORD PTR utime1 sub edx,DWORD PTR utime1+4 mov DWORD PTR utime1,eax mov DWORD PTR utime1+4,edx invoke ReleaseDC,hwnd,hDcw popad ret PaintThread endp end start用SetPixelV这个API绘图,程序中按下大写的P键开始绘图,画出950*750大小的图像都要几秒钟,有什么方法能快速绘图吗?