在API中,绘制数学曲线的函数:
Public Declare Function GdipDrawCurve2 Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, Points As POINTF, ByVal count As Long, ByVal tension As Single) As GpStatus
调用时,Points怎样得到?
敬请高手指点。
谢谢。
Public Declare Function GdipDrawCurve2 Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, Points As POINTF, ByVal count As Long, ByVal tension As Single) As GpStatus
调用时,Points怎样得到?
敬请高手指点。
谢谢。
看看这个
遵嘱,都看了。但没有找到答案。
过去用过绘制弧线的API,相对简单,参数中没有Points和pen参数。现在的难题是不知道怎样设置参数,来调用绘制数学曲线的API函数。
敬请明示。
谢谢。
x As FIXED
y As FIXED
End Typeprivate pp as POINTF'用PP来设置座标值:
debug.print pp.x,pp.y
Private Type FIXED
fract As Integer
Value As Integer
End Type'定义POINTFX类型
Private Type POINTFX
x As FIXED
y As FIXED
End Typeprivate pp as POINTFX'用PP来设置座标值:
debug.print pp.x.fract ,pp.y.fract
从上午试验到现在,还是不得要领。实在是我太笨。
两个问题挡道。
(1)参数中的points不能作为参数类型,试运行时提示错误。
(2)暂时删除这一参数,软件可运行。因为曲线至少需要三个点,所以定义一个数组dians(1 to 4),是pointf数据类型。但调用绘制曲线的API函数,提示编译错误:ByRef参数类型不符。
呈上源码:
Private Sub Command23_Click() '临时调试按钮
Dim wdians(1 To 4) As POINTF
Dim wdianshu As Long
Dim wzhangli As Single
Dim huabi As Long
wdians(1).X = 100: wdians(1).Y = 100: wdians(2).X = 200: wdians(1).Y = 150: wdians(3).X = 400: wdians(3).Y = 50
wdianshu = 3: wzhangli = 1
GdipDrawCurve2 Picture1.hdc, huabi, (wdians()), wdianshu, wzhangli
End Sub耽误您的宝贵时间,真很抱歉。
谢谢。
要这样用:wdians(1).X.Value = 100
'使用Gdiplus.tlb,将其放到system32中,然后添加对其的引用
'手动设置Form的AutoRedraw=True,ScaleMode=Pixels
Option Explicit
Dim lngGraphics As Long
Dim gpP As GpStatus
Dim lngPen1 As Long
Dim lngToken As Long
Dim GpInput As GdiplusStartupInput
Dim p As POINTF
Private Sub Command1_Click()
gpP = GdipCreateFromHDC(Me.hDC, lngGraphics)
gpP = GdipCreatePen1(&H80FF0000, 2, UnitPixel, lngPen1)
p.X = 100
p.Y = 100
gpP = GdipDrawCurve2(lngGraphics, lngPen1, p, 10, 5)
Me.Refresh
End Sub
Private Sub Form_Load()
Dim bolP As Boolean
With Me
.Caption = "GDIPlus范例"
.Width = 960 * 15
.Height = 720 * 15
.Left = (Screen.Width - .Width) * 0.5
.Top = (Screen.Height - .Height) * 0.5
End With
GpInput.GdiplusVersion = 1
If lngToken = 0 Then bolP = (GdiplusStartup(lngToken, GpInput) = Ok)
End Sub
按东方所教格式,定义Type,提示是“无效内部过程”。定义pp,报错:“子程序和函数中的属性无效”。
至于tlb,实在是啃不动。
绘制数学曲线的API函数:
Private Declare Function GdipDrawCurve2 Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, Points As POINTF, ByVal count As Long, ByVal tension As Single) As Long
如何调用?
谢谢。
'手动设置Form的AutoRedraw=True,ScaleMode=Pixels
Option Explicit
Dim lngGraphics As Long
Dim gpP As GpStatus
Dim lngPen1 As Long
Dim lngToken As Long
Dim GpInput As GdiplusStartupInput
Dim p(0 To 99) As POINTF
Private Sub Command1_Click()
Dim intP As Integer
Me.Cls
gpP = GdipCreateFromHDC(Me.hDC, lngGraphics)
gpP = GdipCreatePen1(&H80808080, 2, UnitPixel, lngPen1)
For intP = 0 To 99
p(intP).X = intP * 10
p(intP).Y = 200 + 50 * Sin((intP * 10) / 100 * 2 * 3.1415926)
Next intP
gpP = GdipDrawCurve2(lngGraphics, lngPen1, p(0), 100, 10)
Me.Refresh
End Sub
Private Sub Form_Load()
Dim bolP As Boolean
With Me
.Caption = "GDIPlus范例"
.Width = 960 * 15
.Height = 720 * 15
.Left = (Screen.Width - .Width) * 0.5
.Top = (Screen.Height - .Height) * 0.5
End With
GpInput.GdiplusVersion = 1
If lngToken = 0 Then bolP = (GdiplusStartup(lngToken, GpInput) = Ok)
End Sub