Iam calling the sub below a number of times until the picture is drawn. But when i Minimized the form the drawing clears.
can anyboddy help please.
Sub drawscreen()
Dim g As Graphics
Dim bmap As Bitmap
bmap = New Bitmap(picgame.Width, picgame.Height, _
picgame.CreateGraphics)
g = Graphics.FromImage(bmap)
Dim p As New Point()
p.X = 1 + x + (i * 4)
p.Y = y + (j * 4)
If bmap.GetPixel(p.X, p.Y) = System.Drawing.Color.FromArgb(255, 255, 255) Then
v(&HF) = 1
picgame.CreateGraphics.DrawLine(Pens.Black, 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
Else
picgame.CreateGraphics.DrawLine((Pens.White), 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
End If
g.Dispose()
end sub
I have tryed picgame.Image = bmap but it did not draw.
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
DrawSprite() ' calls drawscreen()
MyBase.OnPaint(e)
End Sub
thanks karl
can anyboddy help please.
Sub drawscreen()
Dim g As Graphics
Dim bmap As Bitmap
bmap = New Bitmap(picgame.Width, picgame.Height, _
picgame.CreateGraphics)
g = Graphics.FromImage(bmap)
Dim p As New Point()
p.X = 1 + x + (i * 4)
p.Y = y + (j * 4)
If bmap.GetPixel(p.X, p.Y) = System.Drawing.Color.FromArgb(255, 255, 255) Then
v(&HF) = 1
picgame.CreateGraphics.DrawLine(Pens.Black, 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
Else
picgame.CreateGraphics.DrawLine((Pens.White), 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
End If
g.Dispose()
end sub
I have tryed picgame.Image = bmap but it did not draw.
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
DrawSprite() ' calls drawscreen()
MyBase.OnPaint(e)
End Sub
thanks karl