找回密码
 加入
搜索
查看: 2075|回复: 3

[图形处理] 如何用GDI绘制颜色竖条显示?【已解决】

[复制链接]
发表于 2016-3-23 19:19:54 | 显示全部楼层 |阅读模式
本帖最后由 kemyliu 于 2016-3-26 15:29 编辑

如题,如何用GDI绘制颜色竖条显示。大神帮忙一下!
发表于 2016-3-23 20:39:15 | 显示全部楼层
个人认为
如果没有其它绘图操作 直接用pic控件载入图片最为简洁
如果有其它绘图操作 光会绘制几条竖线也没多大用处…
发表于 2016-3-24 08:17:35 | 显示全部楼层
用wia来画?
附上vbs代码:
Set v = CreateObject("WIA.Vector")
For i = 1 To 20 * 200
        v.Add &HFF0000FF
Next
Set Img = v.ImageFile(20,200)
Img.SaveFile "Blue." & Img.FileExtension
 楼主| 发表于 2016-3-26 15:28:45 | 显示全部楼层
自己照猫画虎弄出来了,分享一下代码。
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example()

Func Example()
        Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

        ; Create GUI
        $hGUI = GUICreate("Form1", @DesktopWidth+5, @DesktopHeight+50, -1, -1,$WS_POPUP,$WS_EX_TOPMOST)
        GUISetState(@SW_SHOW)
        _GDIPlus_Startup()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
        _GDIPlus_GraphicsClear($hGraphic, 0x00000000)

        $hBrush1 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
        $hBrush2 = _GDIPlus_BrushCreateSolid(0xFFFFFF00)
        $hBrush3 = _GDIPlus_BrushCreateSolid(0xFF6666FF)
        $hBrush4 = _GDIPlus_BrushCreateSolid(0xFF00CC00)
        $hBrush5 = _GDIPlus_BrushCreateSolid(0xFFCC33FF)
        $hBrush6 = _GDIPlus_BrushCreateSolid(0xFFFF0000)
        $hBrush7 = _GDIPlus_BrushCreateSolid(0xFF0000FF)
        $hBrush8 = _GDIPlus_BrushCreateSolid(0xFF000000)

        $hRegion1 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*0, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion2 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*1, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion3 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*2, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion4 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*3, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion5 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*4, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion6 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*5, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion7 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*6, 0, @DesktopWidth/8, @DesktopHeight+50)
        $hRegion8 = _GDIPlus_RegionCreateFromRect(@DesktopWidth/8*7, 0, @DesktopWidth/8, @DesktopHeight+50)

        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush1)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush2)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion3, $hBrush3)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion4, $hBrush4)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion5, $hBrush5)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion6, $hBrush6)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion7, $hBrush7)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion8, $hBrush8)
        _GDIPlus_GraphicsDrawString($hGraphic, "Press ESC To EXIT.", 50, @DesktopHeight-10)
        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; Clean up resources
        _GDIPlus_RegionDispose($hRegion1)
        _GDIPlus_RegionDispose($hRegion2)
        _GDIPlus_RegionDispose($hRegion3)
        _GDIPlus_RegionDispose($hRegion4)
        _GDIPlus_RegionDispose($hRegion5)
        _GDIPlus_RegionDispose($hRegion6)
        _GDIPlus_RegionDispose($hRegion7)
        _GDIPlus_RegionDispose($hRegion8)
        _GDIPlus_BrushDispose($hBrush1)
        _GDIPlus_BrushDispose($hBrush2)
        _GDIPlus_BrushDispose($hBrush3)
        _GDIPlus_BrushDispose($hBrush4)
        _GDIPlus_BrushDispose($hBrush5)
        _GDIPlus_BrushDispose($hBrush6)
        _GDIPlus_BrushDispose($hBrush7)
        _GDIPlus_BrushDispose($hBrush8)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
EndFunc   ;==>Example
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 06:21 , Processed in 0.074888 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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