DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Drawing line in pictureBox (http://www.daniweb.com/forums/thread167166.html)

pete08 Jan 9th, 2009 5:03 am
Drawing line in pictureBox
 
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

LizR Jan 9th, 2009 5:07 am
Re: Drawing line in pictureBox
 
Because you need to paint it there each time the picture is painted most likely

pete08 Jan 9th, 2009 5:28 am
Re: Drawing line in pictureBox
 
I'm working on application for WinMobile and there isn't OnPaint method there...

LizR Jan 9th, 2009 5:36 am
Re: Drawing line in pictureBox
 
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.

pete08 Jan 9th, 2009 6:11 am
Re: Drawing line in pictureBox
 
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.

LizR Jan 9th, 2009 6:25 am
Re: Drawing line in pictureBox
 
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

pete08 Jan 9th, 2009 6:29 am
Re: Drawing line in pictureBox
 
Do You have some example code, plz

Durva Jan 9th, 2009 8:03 am
Hello,
Please tell me the some references about c#.

hieuuk Jan 9th, 2009 8:56 am
Re: Drawing line in pictureBox
 
Won't the drag and drop method for control work in WM?


All times are GMT -4. The time now is 9:21 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC