Results 1 to 14 of 14

Thread: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Resolved [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?

    Is there a GDIplus equivalent of GDI's Polyline?
    Code:
    Declare Function Polyline Lib "gdi32" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Edited: One of my favorite GDI+ related sites: http://www.jose.it-berater.org/gdiplus/iframe/index.htm
    Last edited by LaVolpe; Jan 19th, 2019 at 03:26 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Is there a GDIplus equivalent of GDI's Polyline?

    direct2d has a lot of stuff, since im only working with bitmap and some rectangles and brushes i dont know how to do the geometry.
    just check this: https://docs.microsoft.com/en-us/win...tries-overview

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    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.

    Brenker

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is there a GDIplus equivalent of GDI's Polyline?

    Quote Originally Posted by Brenker View Post
    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"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    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).

    Brenker

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is there a GDIplus equivalent of GDI's Polyline?

    Quote Originally Posted by Brenker View Post
    I found that I must convert the passed array from POINTL to POINTF first (GdipAddPathLineI accepts POINTL).
    For longs instead of singles, use GdipAddPathLine2I
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    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.

    Brenker

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is there a GDIplus equivalent of GDI's Polyline?

    Quote Originally Posted by Brenker View Post
    LaVolpe,

    GdipAddPathLine2I doesn't accept POINTL either; to use it I must convert from POINTL to POINT then.
    If POINT and POINTL are defined the same, i.e.,
    Code:
    X As Long
    Y As Long
    Then it can accept either, just depends on how you define your API declaration. In my projects where I use that function, I define it like this
    Code:
    Private Declare Function GdipAddPathLine2I Lib "GdiPlus.dll" (ByVal mpath As Long, _
        ByRef mPoints As Any, _
        ByVal mCount As Long) As Long
    This allows me to pass reference as ptArray(0) where ptArray(0) is defined as POINT,POINTL,POINTAPI, whatever as long as the UDT members are Longs.

    From our above discussion I know now that there is no GDIplus equivalent of GDI's Polyline
    Not sure how that is a correct statement, when GdipDrawLines & GdipDrawLinesI do what Polyline does
    Last edited by LaVolpe; Jan 19th, 2019 at 07:42 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    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.
    Attached Images Attached Images  

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    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.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?

    I've assembled a quickie in the attached Test_Project.ZIP.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Brenker; Jan 19th, 2019 at 10:05 PM.

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: [RESOLVED] Is there a GDIplus equivalent of GDI's Polyline?

    Quote Originally Posted by Brenker View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width