Image Clear

adude

Member
Joined
Aug 19, 2003
Messages
22
Hi,

I am trying to make a crop tool for a picture. Right now, Im making the actual crop tool. I want it to be a simple box that is draggable & resizes to the mouse over a picture(box).

Ive tried many different things and nothing has worked (or worked well):

I tried using graphics, but I needed to clear the graphics so that the past boxes wont be seen (so that it drags). However, when I cleared the graphics, it cleared the image in the picturebox.

So I made it DrawImage each time it cleared... But this made it so flashy you couldnt see the dragging of the box (especially since Im working with big picture files).

I also tried resizing labels to look like lines... But this too was too slow and didnt seem like it was a good way to do it.

I would appreciate any help any one could give, primarily on how to keep an image loaded while clearing the graphics on it. Or, how to have "layers" of graphics so that I could clear "Layer 2 - The Crop Tool" but not "Layer 1 - The Image".

Thanks in advance.

(Btw - I love the new look of the site. Good job!)
 
I wrote a Drag-Rect-Function a while ago.. but i found it and modified it to fit your needs!

Im sure you will be very pleased with the attached code.. its pretty fast and looks good.. Im so great.. [Broken External Image]:http://computerhelp.forum/images/smilies/biggrin.gif [Broken External Image]:http://computerhelp.forum/images/smilies/wink.gif

Hope this helps!

Andreas

...would be nice if you gave credit to my work (mention me somewhere in your "About" - Form or something like this..) since it took me a long time to write the initial version of the DragRect.... but you dont have to do it..

[edit]found a small bug.. fixed in the new uploaded version.. [/edit]
 

Attachments

Last edited by a moderator:
Thanks a lot for your time... but I dont know how to implement the code :confused: . I ran it without any modifications and nothing happened. Im not too advanced of a VB programmer so I dont understand how, for example, CropControl.onMouseDown can be "linked" to the pnlEditPic.MouseDown event.

To get it to even show the original pic I had to add some code, like:

[VB]

Dim myCropC As New CropControl

myCropC.LoadImage(ofd.FileName)

pnlEditImage.BackgroundImage = New Bitmap(ofd.FileName)

[/VB]

...otherwise it gave me an error: "Object reference not set to an instance of an object." on the LoadImage command. Im guessing that Im not doing something that I should be.

(I d/led the attachment at 5:00 pm on March 15, so it shouldve had that "bug" fixed)

I would appreciate any help on this. Thanks again.
 
yeah the version you downloaded should be okay.. I just downloaded the project myself and it runs the way I wanted it to run. to see the app in action youd have to simply follow these steps:

1. download the attachment from the post above
2. unzip the file to any folder you like
3. doubleclick the "DragRect.sln"-File (if you use VS.NET 2003 youre asked whether you want to convert the project - click "Yes")
4. when the project is loaded hit F5 or the small arrow in the tool bar (you know the one that points to the right)
5. wait until you see a new Window (since I didnt change it its title is "Form1")
6. therere two buttons on the Form one with the text "Show Cropped" and the other one with "Load Image"
7. hit the "Load Image"-Button
8. A dialog will popup
9. Select any image-File and hit Ok on the Dialog
10. youll see the Image painted in the Left part of the form
11. move the mouse above the image - into the Rectangle that is drawn on it
12. when you move the mousepointer above a corner of this Rectangle youre able to resize it
13. resize the rectangle that it covers the part of the Image you want to be cropped
14. hit the other button ("Show Cropped")
15. voil
 

Attachments

Last edited by a moderator:
I dont know what happened, but now that I re-downloaded it, it works (I think maybe the server didnt update your update right away?).

Either way, I appreciate the code :). Ill be sure to add "Hamburger1984 of Xtreme .Net Talk" in my About Section.

:D This site is the best
 
Back
Top