Dim graphics As Long
Dim bitmap As Long
Dim pen As Long
Dim aaa As GdiplusStartupInput
Dim token As Long
Private Enum pathpoint
PathPointTypeStart = 0 ' 起点
PathPointTypeLine = 1 '直线端点
PathPointTypeBezier = 3 ' 贝塞尔(曲线的控制)点
PathPointTypePathTypeMask = &H7 ' 点类型掩码(只保留低三位)
PathPointTypePathDashMode = &H10 ' 未使用
PathPointTypePathMarker = &H20 '标记点(用于路径分段)
PathPointTypeCloseSubpath = &H80 ' 闭子路径(图形)的终点
PathPointTypeBezier3 = 3 ' 同PathPointTypeBezier
End EnumPrivate Sub Form_Load()
Dim point(5) As POINTF
Dim i As Integer
Dim bt(5) As Byte
Dim path As Long
' ReDim point(5) As POINTF
For i = 0 To 5
point(i).X = 10 * i
point(i).Y = 10 * i
bt(i) = 1
Next
aaa.GdiplusVersion = 1
GdiplusStartup token, aaa, Null
GdipCreateFromHDC Picture1.hDC, graphics
GdipCreatePen1 &HFF000000, 10, UnitPixel, pen
GdipDrawLineI graphics, pen, 10, 10, 200, 200
i = GdipCreatePath2(point(), bt(), 6, FillModeAlternate, path)
Picture1.Refresh
End SubPrivate Sub Form_Unload(Cancel As Integer)
GdipDeletePen pen '删除这个笔(pen)
GdipDeletePath path
GdipDisposeImage bitmap
GdipDeleteGraphics graphics '释放graphics占用的内存
GdiplusShutdown token
End Sub
创建路径一直创建不成功,请问一下GdipCreatePath2参数该怎么传递?
Dim bitmap As Long
Dim pen As Long
Dim aaa As GdiplusStartupInput
Dim token As Long
Private Enum pathpoint
PathPointTypeStart = 0 ' 起点
PathPointTypeLine = 1 '直线端点
PathPointTypeBezier = 3 ' 贝塞尔(曲线的控制)点
PathPointTypePathTypeMask = &H7 ' 点类型掩码(只保留低三位)
PathPointTypePathDashMode = &H10 ' 未使用
PathPointTypePathMarker = &H20 '标记点(用于路径分段)
PathPointTypeCloseSubpath = &H80 ' 闭子路径(图形)的终点
PathPointTypeBezier3 = 3 ' 同PathPointTypeBezier
End EnumPrivate Sub Form_Load()
Dim point(5) As POINTF
Dim i As Integer
Dim bt(5) As Byte
Dim path As Long
' ReDim point(5) As POINTF
For i = 0 To 5
point(i).X = 10 * i
point(i).Y = 10 * i
bt(i) = 1
Next
aaa.GdiplusVersion = 1
GdiplusStartup token, aaa, Null
GdipCreateFromHDC Picture1.hDC, graphics
GdipCreatePen1 &HFF000000, 10, UnitPixel, pen
GdipDrawLineI graphics, pen, 10, 10, 200, 200
i = GdipCreatePath2(point(), bt(), 6, FillModeAlternate, path)
Picture1.Refresh
End SubPrivate Sub Form_Unload(Cancel As Integer)
GdipDeletePen pen '删除这个笔(pen)
GdipDeletePath path
GdipDisposeImage bitmap
GdipDeleteGraphics graphics '释放graphics占用的内存
GdiplusShutdown token
End Sub
创建路径一直创建不成功,请问一下GdipCreatePath2参数该怎么传递?
在VB中用Declare语句声明是无效的。
另外,下面这句引用参数是不正确的
i = GdipCreatePath2(point(), bt(), 6, FillModeAlternate, path)
应该是这样的:
i = GdipCreatePath2(point(0), bt(0), 6, FillModeAlternate, path)下面是一段测试通过的代码:
path1Points(0).x = 100
path1Points(0).y = 100
path1Points(1).x = 190
path1Points(1).y = 120
path1Points(2).x = 200
path1Points(2).y = 200
path1Points(3).x = 90
path1Points(3).y = 180
path1Points(4).x = 100
path1Points(4).y = 100
path1Types(0) = 0
path1Types(1) = 1
path1Types(2) = 1
path1Types(3) = 1
path1Types(4) = 129
GdipCreateSolidFill Colors.Blue, path1Brush
pathStat = GdipCreatePath2(path1Points(0), path1Types(0), 5, FillModeAlternate, path1)
Dim tGraphics As Long
GdipCreateFromHDC hDC, tGraphics
GdipFillPath tGraphics, path1Brush, path1必须引用类型库中的GdipCreatePath2.