ashfinal 发表于 2012-5-31 21:14:53

【已解决】无奈了,为啥GDI+设置填充颜色后绘图缺了一块?

本帖最后由 ashfinal 于 2012-6-1 01:54 编辑

#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
_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+4*$aPosX-2,$PicPos+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没设置画刷颜色前是完整的正方形,设置后上面就缺少了一块 - -
有码,请各位大大们帮忙看看哪有问题啊,在线等。

bdancerlc 发表于 2012-5-31 21:58:42

明显不是缺了一块,是图片的高度变小了!...

yhxhappy 发表于 2012-6-1 00:22:46

Opt("PixelCoordMode", 2)

ashfinal 发表于 2012-6-1 01:51:29

回复 3# yhxhappy

哈哈 感谢万分 就是没想到改这块啊 {:face (427):}

zmdzhxj 发表于 2019-7-27 17:58:21

运行好慢啊
页: [1]
查看完整版本: 【已解决】无奈了,为啥GDI+设置填充颜色后绘图缺了一块?