【发布时间】:2015-03-15 09:33:46
【问题描述】:
我以前使用 WriteableBitmapEX 库在鼠标移动的任何地方裁剪图像。好像有点慢。
我想在任何随机像素处裁剪图像,并且我想将该裁剪区域分配给另一个图像控件。
我的问题是,当我使用 clip 属性时,我只得到了被剪裁的区域,而整个图像正在运行。我希望图像完全位于背景中,但应将裁剪区域分配给图像控件。
这是代码。
private void Image1_Tapped(object sender, TappedRoutedEventArgs e)
{
int CropArea = 50;
int PointShift = CropArea / 2;
var _rect = new RectangleGeometry();
Point pt;
pt = e.GetPosition(Image1);
_rect.Rect = new Rect(pt.X - PointShift, pt.Y - PointShift, 100, 100);
Image1.Clip = _rect;
MagnifyTip.Image1.Source=Image1.clip; //This is what I want to do . Its not happenning.
}
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Image x:Name="Image1" Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Tapped="Image1_Tapped" >
<Image.Source >
<BitmapImage UriSource="Assets/Jellyfish.png" />
</Image.Source>
</Image>
</Grid>
欢迎任何更好的解决方案,因为我必须继续在图像周围移动手指并在我的用户控件的图像框中获取更新的逐像素裁剪图像
【问题讨论】:
标签: c# winrt-xaml rectangles windows-rt