如何用GDI绘制颜色竖条显示?【已解决】
本帖最后由 kemyliu 于 2016-3-26 15:29 编辑如题,如何用GDI绘制颜色竖条显示。大神帮忙一下!
http://img3.douban.com/view/note/large/public/p8031500.jpg 个人认为
如果没有其它绘图操作 直接用pic控件载入图片最为简洁
如果有其它绘图操作 光会绘制几条竖线也没多大用处… 用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 自己照猫画虎弄出来了,分享一下代码。#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
页:
[1]