想自画如Word中的标注图形,然后在图形内添加上文字。
初学GDI+,储备知识太少,只会用区域画出图形轮廓,却又无法实现描边,请问应该如何画出如下的四种图形?
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hMatrix, $hPath2
; 创建 GUI
$iW = 600
$iH = 600
$hGUI = GUICreate("GDI+ UDF 示例", $iW, $iH)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;在句柄指定的窗口创建图形对象
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;设置图形对象渲染质量(抗锯齿)
_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
$hPath = _GDIPlus_PathCreate() ;创建新路径对象
_GDIPlus_PathAddRectangle($hPath, 100, 100, 200, 100)
$hRegion1 = _GDIPlus_RegionCreateFromPath($hPath)
;$hRegion1 = _GDIPlus_RegionCreateFromRect(100, 100, 200, 100)
$hPath2 = _GDIPlus_PathCreate()
Local $aPoints[4][2] = [[3]]
$aPoints[1][0] = 130
$aPoints[1][1] = 190
$aPoints[2][0] = 200
$aPoints[2][1] = 190
$aPoints[3][0] = 90
$aPoints[3][1] = 230
_GDIPlus_PathAddPolygon($hPath2, $aPoints)
$hRegion2 = _GDIPlus_RegionCreateFromPath($hPath2)
_GDIPlus_RegionCombineRegion($hRegion1, $hRegion2, 2)
_GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
;_GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
;_GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; 清理资源
_GDIPlus_PathDispose($hPath2)
_GDIPlus_PathDispose($hPath)
_GDIPlus_RegionDispose($hRegion1)
_GDIPlus_RegionDispose($hRegion2)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Example
|