define crop from picturebox?
-
Hey all, I need to load a photo, Display it in a picturebox then "draw" a rectangle area that i want to crop an example would be if i wanted to make a head shot out of a regular photo i know how to find and load the photo in to the picture box but I'm not sure how to define the crop i want any ideas
-
Hey all, I need to load a photo, Display it in a picturebox then "draw" a rectangle area that i want to crop an example would be if i wanted to make a head shot out of a regular photo i know how to find and load the photo in to the picture box but I'm not sure how to define the crop i want any ideas
add in some mouse events for the picture box. When the user clicks with the mouse, register its location (so, a start point) When the user releases, register the loaction and you have an end point. Now, create a new bitmap the same width and hieght as your selected area. Create a new graphics object from your new bitmap (Graphics.FromImage) Then draw the selected area of the picture box's image, to your new bitmap Rectangle srcRect = new Rectangle(start.x, start.y, end.x-start.x, end.y-start.y) myGraphics.DrawImage(myPictureBox.Image, 0,0, srcRect, GraphicsUnit.Pixel) Then, set your pictures image to the bitmap you created earlier. Don't forget to dispose of your graphics objects and whatnot. You also may need to add some checking between the start and end points, so you don't have any negative values around. As for drawing the rectangle you want to crop as your dragging the mouse, register for the OnPaint event, and draw a rectangle between the start point, and the current location of the mouse. I hope i havn't been to confusing there, i just kinda typed as i thought.
My current favourite word is: Waffle Cheese is still good though.