943,675 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 4862
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
May 16th, 2005
1

Help, Implementation of a selection tool

Expand Post »
Hi,

I would like to implement a selection tool that is used for images. It selects a part of an image to enable the user for any further usage.

So, what is the simplest way to do such a thing?!

Any help will be welcome
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
fkhaeer is offline Offline
4 posts
since May 2005
May 16th, 2005
0

Re: Help, Implementation of a selection tool

What?
You want to be able to select part of an image so the user can have further usage? Please rephrase
Reputation Points: 46
Solved Threads: 2
Junior Poster
Iron_Cross is offline Offline
117 posts
since Jul 2003
May 16th, 2005
0

Re: Help, Implementation of a selection tool

My application deals with images. I want the user to select a part of an image, a text in the image for example. That selection part will be saved, copied, moved or any thing :evil:

I hope you could understand now

I am waiting.......
Reputation Points: 11
Solved Threads: 0
Newbie Poster
fkhaeer is offline Offline
4 posts
since May 2005
May 17th, 2005
0

Re: Help, Implementation of a selection tool

By the way, I found in somewhare, what i want is called: rubberband.

Regards..
Reputation Points: 11
Solved Threads: 0
Newbie Poster
fkhaeer is offline Offline
4 posts
since May 2005
May 30th, 2005
0

Re: Help, Implementation of a selection tool

Hi..

any HELPING IDEA!!!
Reputation Points: 11
Solved Threads: 0
Newbie Poster
fkhaeer is offline Offline
4 posts
since May 2005
Apr 12th, 2009
0

Re: Help, Implementation of a selection tool

hi
u can use GDI+ in c# and implement selection tool with my own i
i used MouseDownevent , MouseMoveevent , MouseUpevent and PaintEvent

declare refernce of Point as start point for ex:
Point startPoint = Point.empty;
Write in Mouse Down event:
startPoint = new (e.X,e.Y);
Write in Mouse Move event
Graphics g = this.CreateGraphics()l
g.DrawRectangle(Pens.Red,startPoint.X,startPoint.Y,
e.X-startPoint.X,e.Y-startPoint.Y);

that`s it
sorry i did not send the code because am work here and unfortunlly i don`t have c# editor . and sorry i forget daniweb convention for writting code ;
Reputation Points: 28
Solved Threads: 5
Light Poster
BlackSun is offline Offline
46 posts
since Feb 2008
Apr 13th, 2009
0

Re: Help, Implementation of a selection tool

As BlackSun explained, you will need to manage it yourself using the image Graphics. It is a bit more complicated than the example above, but should move you into the right direction. The image onPaint event will have to remember that you have an active selection (the rectangle, and its deminsions) so that if you refresh the form, the selection will be persistent. You may want to use a popup menu, or something to grab that selection of the image and copy it to another bitmap object for processing (send to file, drag drop, whatever).
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006
May 12th, 2011
0
Re: Help, Implementation of a selection tool
Hi,
I've tried BlackSun solution, but I can't see the rectangle.
I've brought the picturebox to background, and still the rectangle is invisible.

do someone have an idea?
Thanx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Seffix is offline Offline
3 posts
since May 2011
May 12th, 2011
0
Re: Help, Implementation of a selection tool
Are you drawing the rectangle inside of the Paint event of the picture box ?
Need to, and sending the picturebox to the background has no effect because you are drawing on top of the object no matter where it is in the Z order.
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006
May 13th, 2011
0
Re: Help, Implementation of a selection tool
This is what I wrote:
  1. private void pictureBox_MouseDown(object sender, MouseEventArgs e)
  2. {
  3. start = true;
  4. startPoint = e.Location;
  5. }
  6.  
  7. private void pictureBox_MouseMove(object sender, MouseEventArgs e)
  8. {
  9. if (start) //if the mouse is pressed
  10. {
  11. //set rectangle size&location
  12. rect.X = startPoint.X;
  13. rect.Y = startPoint.Y;
  14. rect.Width = e.X - startPoint.X;
  15. rect.Height = e.Y - startPoint.Y;
  16.  
  17. //force the form to redrawn
  18. this.Invalidate();
  19. }
  20. }
  21.  
  22. private void pictureBox_Paint(object sender, PaintEventArgs e)
  23. {
  24. graph = e.Graphics;
  25. graph.DrawRectangle(Pens.Red, rect.Top, rect.Left, rect.Width, rect.Height);
  26. }

And still I can't see the rectangle.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Seffix is offline Offline
3 posts
since May 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Equate the content of a combo box
Next Thread in C# Forum Timeline: 2D draw lines, line objects stored in listbox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC