GDI+如何画像Word中的标注图形?
想自画如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 = []
$aPoints = 130
$aPoints = 190
$aPoints = 200
$aPoints = 190
$aPoints = 90
$aPoints = 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 GDI 做界面很不错~学习 本帖最后由 水木子 于 2017-2-4 11:41 编辑
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $hGUI, $hGraphic, $aPoints, $aPoints2
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
GUISetState(@SW_SHOW)
; Draw a polygon
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate(0xffff0000, 2)
$aPoints = 12
$aPoints = 100
$aPoints = 100
$aPoints = 150
$aPoints = 150
$aPoints = 100
$aPoints = 200
$aPoints = 150
$aPoints = 200
$aPoints = 175
$aPoints = 175
$aPoints = 200
$aPoints = 200
$aPoints = 250
$aPoints = 200
$aPoints = 200
$aPoints = 150
$aPoints = 250
$aPoints = 100
$aPoints = 200
$aPoints = 100
$aPoints = 175
$aPoints = 125
$aPoints = 150
$aPoints = 100
_GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints, $hPen)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Example
回复 3# 水木子
谢谢水木子大侠的关注,我查阅了许多,最后也只能通过画多边形或路径组合画出简单的三个来,但对小箭头的所指方向的不确定性,以其与矩形或椭圆的连结点坐标判断上力不从心,无法做到像Word中那样设置自如。目前,现在这个问题我只能再等一等了,等用到这儿再继续折腾吧!再次感谢,敬礼!!!
页:
[1]