Crop image from user input

I am creating a C # application to take pictures of visitors for ID badges. I found a C # wrapper for webcams so that you can easily take a picture, however I need to set the images to a certain number of pixels, ideally when people's head fills most of the area.

I guess the best way to do this is to let the end user drag a rectangle over the original image, with a fixed x and y ratio, enclosing the face of the face. This will allow you to crop the image and make any necessary resolution adjustments.

Does anyone know of an example like this? I think I know how to make a rectangle and get the coordinates to crop the image, other than fixing the x and y ratio. Obviously an example would be faster than trying to write my own.

+1


a source to share


2 answers


Found an article that does something like this:



http://www.codeproject.com/KB/graphics/crop_and_resize.aspx

+2


a source


Since .Net 3.0, System.Windows.Media.Imaging provides a class CroppedBitmap

that inherits from BitmapSource

. Its constructor takes a BitmapSource

and a Int32Rect

. If you pass this original image and your rectangle, it will return the cropped image as BitmapSource

.



0


a source







All Articles