Re: Is there a GDIplus equivalent of GDI's Polyline?
Yes, for both paths & simple drawing commands. For example:
Drawing multiple lines: GdipDrawLines which takes in parameters similar to GDI Polyline
Adding multiple lines to a path: GdipAddPathLine2 which takes in parameters similar to GDI Polyline
Per MSDN, following applies. I have not tested whether this is true/false with GDI+. In fact, I have not even tested whether any GDI+ functions affect VB's CurrentX & CurrentY values.
Unlike the LineTo or PolylineTo functions, the Polyline function neither uses nor updates the current position
Re: Is there a GDIplus equivalent of GDI's Polyline?
LaVolpe,
For GDI's Polygon function,
Code:
Declare Function Polygon Lib "gdi32" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
We have a GDIplus equivalent
Code:
Private Declare Function GdipDrawPolygonI Lib "gdiplus" (ByVal graphics As Long, ByVal Pen As Long, Points As POINTL, ByVal count As Long) As GpStatus
That is why I am wondering whether there is a GDIplus equivalent of GDI's Polyline function as well.
Yes we can use GDIplus' GdipCreatePath, GdipAddPathLineI, GdipCreatePen1 and GdipDrawPath to arrive at a similar result of GDI's Polyline, but in this case we have to loop through the individual points in the passed array, and make a GdipAddPathLineI call for each of them.
Re: Is there a GDIplus equivalent of GDI's Polyline?
Originally Posted by Brenker
That is why I am wondering whether there is a GDIplus equivalent of GDI's Polyline function as well.
Yes we can use GDIplus' GdipCreatePath, GdipAddPathLineI, GdipCreatePen1 and GdipDrawPath to arrive at a similar result of GDI's Polyline, but in this case we have to loop through the individual points in the passed array, and make a GdipAddPathLineI call for each of them.
Brenker
No you don't
Look at GdipAddPathLine2 vs GdipAddPathLine. Notice the #2 at end of function name. Maybe you didn't catch that in my 1st post.
Insomnia is just a byproduct of, "It can't be done"
Re: Is there a GDIplus equivalent of GDI's Polyline?
LaVolpe,
I've now tested GdipAddPathLine2, I confirm that it is usable. I found that I must convert the passed array from POINTL to POINTF first (GdipAddPathLineI accepts POINTL).
Re: Is there a GDIplus equivalent of GDI's Polyline?
LaVolpe,
GdipAddPathLine2I doesn't accept POINTL either; to use it I must convert from POINTL to POINT then.
From our above discussion I know now that there is no GDIplus equivalent of GDI's Polyline, as in the case of GDIplus' GdipDrawPolygonI for GDI's Polygon. However, we can arrive at a similar result using GDIplus calls per my posting #4, or instead of using GdipAddPathLineI, use GdipAddPathLine2 or GdipAddPathLine2I suitably.
Thank you for entering the discussion. Thread is considered satisfactorily closed.
Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?
I confirm that both POINTL and POINT are with
x As Long
y As Long
The function used in the testing is as follows:
Code:
Public Sub PolylineGDIplus(inDIB As clsDIB, inPt() As POINTL, ByVal inPtCtn As Long, ByVal inBrushSize As Long, _
ByVal inColor As Long, Optional ByVal inAlpha As Integer = 255, Optional ByVal inFilled As Boolean = False, _
Optional ByVal inFillMode As Long = 0)
If I don't do a conversion from POINTL to POINT, a message would be flagged per screenshot below.
Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?
Not sure how you are defining your GDI+ declarations. In this example, no error
Code:
Private Type POINTL
X As Long
Y As Long
End Type
Private Sub Command2_Click()
Dim hPath As Long
Dim pts() As POINTL
ReDim pts(0 To 3)
pts(1).X = 100
pts(2).X = 100: pts(2).Y = 100
pts(3).Y = 100
GdipCreatePath 1, hPath
If GdipAddPathLine2I(hPath, pts(0), 4) = 0& Then
Stop ' success
End If
GdipDeletePath hPath
End Sub
Insomnia is just a byproduct of, "It can't be done"
Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?
I don't define POINTL within the calling Form, it is declared in a BAS:
Code:
Private Type POINT
x As Long
y As Long
End Type
Public Type POINTL
x As Long
y As Long
End Type
Private Type POINTF
x As Single
y As Single
End Type
Private Declare Function GdipAddPathLineI Lib "gdiplus" (ByVal path As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As GpStatus
Private Declare Function GdipAddPathLine2 Lib "gdiplus" (ByVal path As Long, ByRef points As POINTF, ByVal Count As Long) As GpStatus
Private Declare Function GdipAddPathLine2I Lib "gdiplus" (ByVal path As Long, ByRef points As POINT, ByVal Count As Long) As GpStatus
POINTL is declared Public; if I declared it Private in BAS and the calling Form also had one declared within itself, then the same error message would occur too.
Last edited by Brenker; Jan 19th, 2019 at 09:23 PM.
Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?
Originally Posted by Brenker
I don't define POINTL within the calling Form, it is declared in a BAS:
Code:
Private Type POINT
x As Long
y As Long
End Type
Public Type POINTL
x As Long
y As Long
End Type
Private Type POINTF
x As Single
y As Single
End Type
Private Declare Function GdipAddPathLineI Lib "gdiplus" (ByVal path As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As GpStatus
Private Declare Function GdipAddPathLine2 Lib "gdiplus" (ByVal path As Long, ByRef points As POINTF, ByVal Count As Long) As GpStatus
Private Declare Function GdipAddPathLine2I Lib "gdiplus" (ByVal path As Long, ByRef points As POINT, ByVal Count As Long) As GpStatus
POINTL is declared Public; if I declared it Private in BAS and the calling Form also had one declared within itself, then the same error message would occur too.
POINTL and POINT are the same, but if you declare the API with one (say POINTL) use the same. I mean: don't mix them, decide to call it whether POITL or POINT, but have consistency.
Or always POINTL or always POINT.