Drawing line in pictureBox

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 32
Reputation: pete08 is an unknown quantity at this point 
Solved Threads: 0
pete08 pete08 is offline Offline
Light Poster

Drawing line in pictureBox

 
0
  #1
Jan 9th, 2009
Hi,

I have picture box with some image int it. I want to draw a line on the image. But when code executes, line is there but image is gone.
Here is the code:

bitmap bmp=new bitmap(pb.width,pb.height);
graphics g=new graphics.fromImage(bmp);
pen p=new pen(color.black,5);
g.drawLine(p,0,0,10,10);

Line is there, but underlaying image is gone. What should I do?

Pete
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Drawing line in pictureBox

 
0
  #2
Jan 9th, 2009
Because you need to paint it there each time the picture is painted most likely
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 32
Reputation: pete08 is an unknown quantity at this point 
Solved Threads: 0
pete08 pete08 is offline Offline
Light Poster

Re: Drawing line in pictureBox

 
0
  #3
Jan 9th, 2009
I'm working on application for WinMobile and there isn't OnPaint method there...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Drawing line in pictureBox

 
0
  #4
Jan 9th, 2009
http://msdn.microsoft.com/en-us/libr...l.onpaint.aspx says there should be.

failing that, do a search for captureing from a paintbox/form and saving it as a bmp, so you update the bmp in memory.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 32
Reputation: pete08 is an unknown quantity at this point 
Solved Threads: 0
pete08 pete08 is offline Offline
Light Poster

Re: Drawing line in pictureBox

 
0
  #5
Jan 9th, 2009
Thanks, I have sorted it out.
Another question, do You have any idea how could I drag the image inside pictureBox instead of using scrollbars.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Drawing line in pictureBox

 
0
  #6
Jan 9th, 2009
this was covered in another thread - you need to store the picture in memory, and then copy and show only in the picture box what the user is expecting to see
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 32
Reputation: pete08 is an unknown quantity at this point 
Solved Threads: 0
pete08 pete08 is offline Offline
Light Poster

Re: Drawing line in pictureBox

 
0
  #7
Jan 9th, 2009
Do You have some example code, plz
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1
Reputation: Durva is an unknown quantity at this point 
Solved Threads: 0
Durva Durva is offline Offline
Newbie Poster
 
0
  #8
Jan 9th, 2009
Hello,
Please tell me the some references about c#.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 44
Reputation: hieuuk is an unknown quantity at this point 
Solved Threads: 4
hieuuk hieuuk is offline Offline
Light Poster

Re: Drawing line in pictureBox

 
0
  #9
Jan 9th, 2009
Won't the drag and drop method for control work in WM?
.Net Developer - 3D Game Designer
My Portfolio/Blog: http://www.hieu.co.uk
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC