Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Go Back  Xtreme Visual Basic Talk > > > Draw on a picturebox without removing the picture


Reply
 
Thread Tools Display Modes
  #1  
Old 09-28-2016, 10:56 AM
mcoulter876 mcoulter876 is offline
Newcomer
 
Join Date: Sep 2016
Posts: 2
Question Draw on a picturebox without removing the picture


Hello,
I have a picturebox which I am able to draw on. I chose the color Black to draw and then chose the color White to erase, but it erases the picture that was on the picturebox to begin with instead of just the lines I've drawn.

How do I erase only the lines I've drawn on a PictureBox without erasing any part of the picture loaded into the PictureBox itself?
Reply With Quote
  #2  
Old 09-28-2016, 11:32 AM
mcoulter876 mcoulter876 is offline
Newcomer
 
Join Date: Sep 2016
Posts: 2
Default

Solved it.

Picture1.PaintPicture Picture1.Picture, X - 5, Y - 5, 10, 10, X - 5, Y - 5, 10, 10, vbSrcCopy
Reply With Quote
  #3  
Old 09-30-2016, 09:55 AM
passel's Avatar
passelDraw on a picturebox without removing the picture passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

That is one way to do it.
I've posted some explanations of the graphic contexts of Pictureboxes before, but I don't have time to try to ferret out the best one, so just searching here is apparently one of the first ones. It may not be the clearest description and doesn't provide a written example to play with, but it is probably information you are not aware of.

Since it appears that you have the picture loaded, then you should be able to erase any lines drawn just by issuing a .Cls call, which should not erase the picture. It will just refresh the picturebox from the picture.

If you do a search for rubber band or rubber banding you should fine other techniques for drawing a dynamic moving line over an image.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #4  
Old 09-30-2016, 01:26 PM
Cerian Knight's Avatar
Cerian KnightDraw on a picturebox without removing the picture Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default

I've went to the trouble of explaining layering of a single PictureBox through code:
Code:
'Add a CommandButton and a PictureBox to a new project
Private Sub Command1_Click()
Dim T1 As Single, T2 As Single

'Make sure we can see circles overlapping
Picture1.FillStyle = vbSolid

'Draw to foreground, place in background, then erase foreground
Picture1.AutoRedraw = True 'Expose foreground
Picture1.FillColor = &H0&
Picture1.Circle (100, 100), 100
Picture1.Picture = Picture1.Image 'Copy to background
Picture1.Cls 'Erase foreground
Picture1.AutoRedraw = False 'commit

'Wait 1 second
T1 = Timer: Do: T2 = Timer: Loop While T2 - T1 < 1
'Draw to foreground picture
Picture1.AutoRedraw = True
Picture1.FillColor = &HFF&
Picture1.Circle (150, 150), 100
Picture1.AutoRedraw = False 'commit

'Wait 1 second
T1 = Timer: Do: T2 = Timer: Loop While T2 - T1 < 1
'Draw to screen overlay (non-permanent)
Picture1.AutoRedraw = False 'Expose screen overlay
Picture1.FillColor = &HFF00&
Picture1.Circle (200, 200), 100 'Auto-commit

'Wait 1 second
T1 = Timer: Do: T2 = Timer: Loop While T2 - T1 < 1
'Erase only screen overlay
Picture1.AutoRedraw = False
Picture1.Cls 'Auto-commit

'Wait 1 second
T1 = Timer: Do: T2 = Timer: Loop While T2 - T1 < 1
'Erase foreground and screen overlay
Picture1.AutoRedraw = True
Picture1.Cls
Picture1.AutoRedraw = False 'Commit

'Wait 1 second
T1 = Timer: Do: T2 = Timer: Loop While T2 - T1 < 1
'Erase background, foreground and screen overlay
Picture1.AutoRedraw = False
Picture1.Picture = Nothing 'Auto-commit

End Sub
I wish I had this example when I first started.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply

Tags
chose, color, draw, picture, picturebox, removing


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
 
Draw on a picturebox without removing the picture
Draw on a picturebox without removing the picture
 
-->