473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Drawing in a picture box

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
2 909
vbdog
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
vbdog
5
Fixed Now thanks
Apr 26 '07 #3

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

Similar topics

7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
2
by: padawan | last post by:
I have a winforms control that draws a rectangle for a boarder and positions some graphical elements around the control to create the boarder effect I desired. In the control I have overriden the...
4
by: Christina Androne | last post by:
Hi I want to allow the user to drow some locators on an image and connect the locators with lines. So I tried to put the following code in the onmousedown enevt of the picture: Graphics...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
2
by: George | last post by:
Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in...
1
by: Mchuck | last post by:
I've seen several newsgroup topics everywhere concerning this, as well as a couple of articles from the MSDN website, but this error still baffles me. It has to do with using the...
5
by: Ringo | last post by:
I'm new to C# and want a simple app to display a bitmap that is in bayer format. I searched the group and have an app that can draw pixels in a picturebox using Pset. My problem is that Pset uses...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.