2014-03-29 83 views
0

我正在构建一个Windows Phone 8相机应用程序。照片拍完后,我想让用户选择裁剪图像的特定部分。就像图像中有一些特定的对象一样,当选择裁剪选项时,它应该突出或勾画图像的特定部分,并且应该能够裁剪它,而不是手动裁剪它。裁剪图像的特定部分

任何具体的方法来做到这一点?

谢谢提前。

回答

0

一种方法是将原始图像创建为WriteableBitmap并将TranslateTransform转换为WritableBitmap。类似::

Image workImage = new Image { Source = originalImage, Width = originalWidth, Height = originalHeight }; 

WriteableBitmap writeableBitmap = new WriteableBitmap(newWidth, newHeight); 
writeableBitmap.Render(temporaryImage, new TranslateTransform { X = (originalWidth – newWidth)/-2, Y = (originalHeight – newHEight)/-2 }); 
writeableBitmap.Invalidate(); 

//... or some other stream 
Stream newImageStream = new MemoryStream(); 
//set whatever quality settings you like if 75 is no good 
writeableBitmap.SaveJpeg(newImageStream, newWidth, newHeight, 0, 75); 

// TODO: do something with newImageStream