views:

200

answers:

2

I'm building a c# app to take photos of visitors for ID badges. I have found a c# wrapper for web cams so can take a snap shot easily, however I need to set the images to a certain number of pixels ideally with the persons head filling most of the area.

I imagine the best way to do this is to allow the end user to drag out a rectangle over the initial image with fixed x and y ratio covering the persons face. This would crop the image and do any resolution adjustment necessary.

Does anyone know of an example similar to this? I think I know how to do the rectangle and get my co-ordinates for the image cropping apart from fixing an x and y ratio. Obviously an example would be quicker than trying to write my own.

+1  A: 

Found an article that does something similar:

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

PeteT
A: 

As of .Net 3.0, System.Windows.Media.Imaging provides a CroppedBitmap class that inherits from BitmapSource. Its constructor takes a BitmapSource and an Int32Rect. If you pass it your original image and your rect, it will return a cropped image as a BitmapSource.