找回密码
 加入
搜索
查看: 4377|回复: 4

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

  [复制链接]
发表于 2012-5-31 21:14:53 | 显示全部楼层 |阅读模式
本帖最后由 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[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
没设置画刷颜色前是完整的正方形,设置后上面就缺少了一块 - -
有码,请各位大大们帮忙看看哪有问题啊,在线等。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-5-31 21:58:42 | 显示全部楼层
明显不是缺了一块,是图片的高度变小了!...
发表于 2012-6-1 00:22:46 | 显示全部楼层
Opt("PixelCoordMode", 2)
 楼主| 发表于 2012-6-1 01:51:29 | 显示全部楼层
回复 3# yhxhappy

哈哈 感谢万分 就是没想到改这块啊
发表于 2019-7-27 17:58:21 | 显示全部楼层
运行好慢啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 11:53 , Processed in 0.081097 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表