Results 1 to 18 of 18

Thread: how to draw thousands of lines quickly to a picturebox

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2013
    Posts
    4

    how to draw thousands of lines quickly to a picturebox

    Hi all,

    I have a project to draw thousands of cells of a cellular network to a picturebox. These cells are basically represented by a line.

    My program is looking like this :
    Code:
        Private Sub ReDraw()
            Dim Pi As Double
            Pi = 3.141592654
            Me.PictureBox1.Refresh()
            Dim sectorsize As Integer
            sectorsize = 40
            Dim myGraphics As Graphics = PictureBox1.CreateGraphics
            Dim myFont As Font
            Dim myBrush As Brush
            myBrush = New Drawing.SolidBrush(Color.DarkCyan)
            myFont = New System.Drawing.Font("Verdana", 6)
            Dim myPen As Pen
            myPen = New Pen(Brushes.DarkMagenta, 10)
            For Each row In CellData.CellsTable.Rows
                Dim Temp As String, sector As String, Band As Integer
                Dim X1, Y1, X2, Y2, X5, Y5 As Integer
                X1 = row("X")
                Y1 = row("Y")
                X2 = row("X") + sectorsize * Math.Sin(row("Azimuth") * Pi / 180)
                Y2 = row("Y") - sectorsize * Math.Cos(row("Azimuth") * Pi / 180)
                myGraphics.DrawLine(myPen, X1, Y1, X2, Y2)
            Next row
        End Sub
    The problem that I have is that it takes some time to draw all these lines and I wand to add some more functionality to it and it becomes really slow.
    So how can I make it faster ?

    Here are the possibilities I can think of :

    1) Put screen updating on hold at the beginning of the Sub and resume it at the end. How to do it ?

    2) I know that processing is way faster that print to screen so is there a way of preparing a collection or a buffer and draw it ?

    3) Is it possible to save all these lines as a bitmap and then print bitmap on the screen?

    Thank you
    Fabrice
    Last edited by si_the_geek; Apr 19th, 2013 at 10:07 AM. Reason: added Code tags

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