#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <array.au3>
Opt("GUIOnEventMode", 1)
Opt("PixelCoordMode",0)
$hGUI = GUICreate("Form1", 640, 480, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
$Pic1 = GUICtrlCreatePic("E:\My Document\Pictures\test.jpg", 32, 72, 256, 256)
$Label1 = GUICtrlCreateLabel("",344, 72, 256, 256)
;~ GUICtrlSetBkColor(-1,0x000090)
$Button1 = GUICtrlCreateButton("Button1", 96, 368, 153, 33)
GUICtrlSetOnEvent(-1,"GetColor")
$Button2 = GUICtrlCreateButton("Button2", 344, 368, 161, 33)
;~ GUICtrlSetOnEvent(-1,"ColorPaint")
GUISetState(@SW_SHOW)
Dim $ColorSource[64][64]
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hGUI, "", $Label1))
While 1
WEnd
Func Quit()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
Func GetColor()
GUICtrlSetState($Button1,$GUI_DISABLE)
$PicPos=ControlGetPos("","",$Pic1)
;~ _ArrayDisplay($PicPos)
ToolTip("Wait a minute,working hard...")
For $aPosX=1 to 64
For $aPosY=1 to 64
$ColorSource[$aPosX-1][$aPosY-1]=PixelGetColor($PicPos[0]+4*$aPosX-2,$PicPos[1]+4*$aPosY-2)
$bPenColor=Hex($ColorSource[$aPosX-1][$aPosY-1],6)
$bPen=_GDIPlus_BrushCreateSolid("0xFF"&$bPenColor)
_GDIPlus_GraphicsFillRect($hGraphic, 4*($aPosX-1), 4*($aPosY-1), 4,4,$bPen)
Next
Next
ToolTip("")
GUICtrlSetState($Button1,$GUI_ENABLE)
;~ _ArrayDisplay($ColorSource)
EndFunc
;~ Func ColorPaint()
;~ ;GUICtrlSetState($Button2,$GUI_DISABLE)
;~ For $bPosX=1 to 64
;~ For $bPosY=1 to 64
;~ $bPenColor=Hex($ColorSource[$bPosX-1][$bPosY-1],6)
;~ $bPen=_GDIPlus_BrushCreateSolid("0xFF"&$bPenColor)
;~ _GDIPlus_GraphicsFillRect($hGraphic, 4*($bPosX-1), 4*($bPosY-1), 4,4,$bPen)
;~ ;_GDIPlus_GraphicsFillRect($hGraphic, 4*($bPosX-1), 4*($bPosY-1), 4, 4)
;~ Next
;~ Next
;~ EndFunc
没设置画刷颜色前是完整的正方形,设置后上面就缺少了一块 - -