问题描述
我遇到了难题,无法解决自己的问题.
我想裁剪image1,然后从相机任务中获取图片.
I Have hard problem i can''t fix it my self.
I want to cropping image1 and after get picture from camera task.
private void button1_Click(object sender, RoutedEventArgs e)
{
CameraCaptureTask task = new CameraCaptureTask();
task.Completed += (s, evt) =>
{
if (evt.Error == null && evt.TaskResult == TaskResult.OK)
{
bmpImage.SetSource(evt.ChosenPhoto);
image1.Source = bmpImage;
}
};
task.Show();
}
exp:image1的分辨率为1000px * 1000px
现在我想将button2添加到image1中的图像中:
从x = 100到x = 800
从y = 200到y = 700
所以我有了新的imgae1分辨率700 * 500.
我在 http://msdn.microsoft.com/en-us/library/ms752345中找到了解决方案. aspx [^ ]
此处的代码:
exp: image1 have resolution 1000px * 1000px
now I want add button2 to crop image in image1:
from x=100 to x=800
from y=200 to y=700
so I have new imgae1 resolution 700*500.
I Found Solution for this in http://msdn.microsoft.com/en-us/library/ms752345.aspx[^]
here the code:
// Create an Image element.
Image croppedImage = new Image();
croppedImage.Width = 200;
croppedImage.Margin = new Thickness(5);
// Create a CroppedBitmap based off of a xaml defined resource.
CroppedBitmapcb = new CroppedBitmap(
(BitmapSource)this.Resources["masterImage"],
new Int32Rect(30, 20, 105, 50)); //select region rect
croppedImage.Source = cb; //set image source to cropped
上面的代码是找不到命名空间"CroppedBitmap"的错误.
请帮助我的问题
The code above is error the namespace ''CroppedBitmap'' not found.
please help my problem
推荐答案
using System.Windows.Media.Imaging;
这篇关于如何在WP7中使用C#裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!