我正在构建一个Windows Phone 8相机应用程序。拍完照片后,我想让用户选择裁剪图像的特定部分。就像图像中有一些特定的对象一样,当选择裁剪选项时,它应该突出显示或勾勒出图像的特定部分,并且它应该能够裁剪它,而不是手动裁剪它。
任何具体的方法吗?。
提前致谢。
答案 0 :(得分: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