9月12018
什么是双缓冲绘图,防止闪烁[收集AU3]
在内存中先绘制好图像,再显示到屏幕,防止闪烁的尴尬,这种方法称作双缓冲。
#NoTrayIcon
#include <gdiplus.au3>
$hMain = GUICreate("直接绘图")
GUISetState(@SW_SHOW, $hMain)
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hMain)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000080)
For $X = 0 To 400
_GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
_GDIPlus_GraphicsFillRect($hGraphics, $X, 180, 40, 40, $hBrush)
Sleep(10)
Next
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
;===================================================
$hMain = GUICreate("双缓冲绘图")
GUISetState(@SW_SHOW, $hMain)
_GDIPlus_Startup()
; 画图区
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hMain)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
; 绘制存储器区域(缓冲区)
$hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000080)
For $X = 0 To 400
; 在缓冲器绘制操作
_GDIPlus_GraphicsClear($hBackBuffer, 0xFF000000)
_GDIPlus_GraphicsFillRect($hBackBuffer, $X, 180, 40, 40, $hBrush)
; 绘制屏幕
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Sleep(10)
Next
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hBackBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
扫描二维码,在手机上阅读
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!