|
本帖最后由 yiruirui 于 2010-8-30 09:17 编辑
http://www.autoitx.com/forum.php ... hlight=%CD%B8%C3%F7
这个网站的例子非常经典,小弟想学习学习,遇到了一个函数,理解不了,求能理解的大大们帮帮小弟,万分感激!感激涕零!
Func _ImageDraw($State = "normal", $Case = ""); 利用为PNG图片
Local $hGraphic1, $hBitmap, $hGraphic2
Local $Image[13]
;默认设置
For $i = 1 To 10
$Image[$i] = $NormalImage
Next
$Image[11] = $NormalImage_Small
$Image[12] = $NormalImage_Exit
;创建一个新的位图,这样,原来打开PNG是保持不变
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
; 绘制原 png 到我新创建的位图
Switch $State
Case "normal"
Case "pressed"
Switch $Case
Case 1 To 10
$Image[$Case] = $PressedImage
Case 11
$Image[12] = $PressedImage_Exit
EndSwitch
Case "over"
Switch $Case
Case 1 To 10
$Image[$Case] = $OverImage
Case 11
$Image[12] = $OverImage_Exit
EndSwitch
EndSwitch
For $i = 1 To 10
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], 0, ($i - 1) * 41, 167, 57)
Next
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[11], 3, 411, 111, 53)
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[12], 107, 412, 57, 52)
;清理不再需要的资源
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
;返回新的位图
Return $hBitmap
EndFunc ;==>_ImageDraw |
|