T
Tom
Hey,
I have tried drawing a grid onto my control using the following:
Private Sub VGUI_Grid(...) Handles MyBase.Paint
Dim new_bitmap As Bitmap
' Make a new bitmap that fits the PictureBox.
new_bitmap = New Bitmap(Me.Width, Me.Height)
m_BufferGraphics = Graphics.FromImage(new_bitmap)
' Clear the new bitmap.
m_BufferGraphics.Clear(Me.BackColor)
' Draw the positioning grid.
DrawGrid(new_bitmap)
' Copy the existing bitmap's contents into
' the new bitmap.
If Not (m_BufferBitmap Is Nothing) Then
m_BufferGraphics.DrawImage(m_BufferBitmap, 0, 0)
End If
' Save the new bitmap and graphics objects.
m_BufferBitmap = new_bitmap
Me.BackgroundImage = m_BufferBitmap
End Sub
Private Sub DrawGrid(ByVal bm As Bitmap)
For Y As Integer = 0 To bm.Height - 1 Step GRID_SPACING
For X As Integer = 0 To bm.Width - 1 Step _
GRID_SPACING
bm.SetPixel(X, Y, Color.Silver)
Next X
Next Y
End Sub
But it flickers REALLY badly. I'm sure there is a better way to do this,
i just cannot see how :S
Cheers
I have tried drawing a grid onto my control using the following:
Private Sub VGUI_Grid(...) Handles MyBase.Paint
Dim new_bitmap As Bitmap
' Make a new bitmap that fits the PictureBox.
new_bitmap = New Bitmap(Me.Width, Me.Height)
m_BufferGraphics = Graphics.FromImage(new_bitmap)
' Clear the new bitmap.
m_BufferGraphics.Clear(Me.BackColor)
' Draw the positioning grid.
DrawGrid(new_bitmap)
' Copy the existing bitmap's contents into
' the new bitmap.
If Not (m_BufferBitmap Is Nothing) Then
m_BufferGraphics.DrawImage(m_BufferBitmap, 0, 0)
End If
' Save the new bitmap and graphics objects.
m_BufferBitmap = new_bitmap
Me.BackgroundImage = m_BufferBitmap
End Sub
Private Sub DrawGrid(ByVal bm As Bitmap)
For Y As Integer = 0 To bm.Height - 1 Step GRID_SPACING
For X As Integer = 0 To bm.Width - 1 Step _
GRID_SPACING
bm.SetPixel(X, Y, Color.Silver)
Next X
Next Y
End Sub
But it flickers REALLY badly. I'm sure there is a better way to do this,
i just cannot see how :S
Cheers