如何使用c#windows phone裁剪图像
从图像裁剪矩形
如何从图像中裁剪
代码:
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
imgShow.ImageSource = bmp;
var wb = new WriteableBitmap(bmp);
var sdkImg = ImageConverter.SystemToSdk(wb);
IFaceDetector detector = FaceDetectorFactory.Create(FaceDetectionType.Haar);
var gray = new ImageGray(sdkImg);
FaceRect[] rc = detector.Detect(gray);
MessageBox.Show(rc[0].ToString());
faceRect.Margin = new Thickness(rc[1].Rect.Left / 2, rc[1].Rect.Top / 2, 0, 0);
faceRect.Width = rc[1].Rect.Width;
faceRect.Height = rc[1].Rect.Height;
faceRect.Visibility = System.Windows.Visibility.Visible;
答案 0 :(得分:3)
您可以使用从WriteableBitmap
继承的BitmapSource
类来执行此操作。那里有很多样品,你可以遵循。
参考文献: