| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1367 人关注过本帖
标题:Win32汇编绘图
取消只看楼主 加入收藏
Agdmeg
Rank: 4
来 自:四川成都
等 级:业余侠客
威 望:3
帖 子:101
专家分:201
注 册:2011-8-9
结帖率:92.31%
收藏
已结贴  问题点数:10 回复次数:1 
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大小的图像都要几秒钟,有什么方法能快速绘图吗?
搜索更多相关主题的帖子: color 
2013-04-19 15:22
Agdmeg
Rank: 4
来 自:四川成都
等 级:业余侠客
威 望:3
帖 子:101
专家分:201
注 册:2011-8-9
收藏
得分:0 
看了看网上的,说要用填充函数,版主那么热心,分就给你了
2013-04-21 14:09
快速回复:Win32汇编绘图
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029364 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved