By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Drawing in a picture box

P: 5
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.
Expand|Select|Wrap|Line Numbers
  1. Sub drawscreen()
  2.  
  3. Dim g As Graphics
  4. Dim bmap As Bitmap
  5. bmap = New Bitmap(picgame.Width, picgame.Height, _
  6. picgame.CreateGraphics)
  7.  
  8. g = Graphics.FromImage(bmap)
  9.  
  10. Dim p As New Point()
  11. p.X = 1 + x + (i * 4)
  12. p.Y = y + (j * 4)
  13.  
  14.  
  15. If bmap.GetPixel(p.X, p.Y) = System.Drawing.Color.FromArgb(255, 255, 255) Then
  16. v(&HF) = 1
  17.  
  18. picgame.CreateGraphics.DrawLine(Pens.Black, 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
  19.  
  20. Else
  21. picgame.CreateGraphics.DrawLine((Pens.White), 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
  22.  
  23. End If
  24.  
  25. g.Dispose()
  26. end sub
  27.  
  28. I have tryed picgame.Image = bmap but it did not draw.
  29.  
  30. ProtectedOverridesSub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  31. DrawSprite() ' calls drawscreen()
  32.  
  33. MyBase.OnPaint(e)
  34.  
  35. EndSub
  36.  
thanks karl
Apr 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: 5
Just change the code below but it just draws a pixel then clears the pixel then draws another then clears and so on

Expand|Select|Wrap|Line Numbers
  1. Dim m_imageList As ImageList
  2. m_imageList = New ImageList
  3. m_imageList.ImageSize = New Size(110, 42) 'Change to whatever size you are needing
  4. Dim bmp As New Bitmap(110, 42, Drawing.Imaging.PixelFormat.Format32bppArgb)
  5. Dim g As Graphics
  6. g = Graphics.FromImage(bmp)
  7. bmp.CreateGraphics.DrawLine(.......stuff
  8. g.Dispose()
  9. m_imageList.Images.Add(bmp)
  10. picgame.Image() = m_imageList.Images(0)
  11.  
Apr 26 '07 #2

P: 5
Fixed Now thanks
Apr 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.