图像在WPF中翻转

时间:2009-08-20 21:09:05

标签: wpf reflection image

如何在不使用xaml的情况下将图像反映在wpf中?我有一个带有BitmapImageBrush的矩形作为填充。我希望能够在C#中随意来回翻转这个图像(X轴)。我已经阅读过有关使用ScaleTransform属性的信息,但这似乎只适用于xaml,而这不是我想要的。

这是图像的创建方式:

ImageBrush l = new ImageBrush(new BitmapImage(new Uri(uriPath, UriKind.Relative)));
_animation.Add(l);

_visual = new Rectangle();
_visual.Fill = _animation[0];
_visual.Width = width;
_visual.Height = height;
_visual.Visibility = Visibility.Visible;
_window.GameCanvas.Children.Add(_visual);

_animation是ImageBrushes的列表。 这很简单,但我似乎无法弄清楚如何做到这一点。请帮忙。

1 个答案:

答案 0 :(得分:2)

您仍然可以通过编程方式添加缩放变换,而不是使用xaml。

例如,in this article.

要进行翻转,请将您的缩放变换设置为您想要翻转的方向为负(即,如果是水平,则将x设置为-1,如果您还想调整大小,则设置为-desiredScale)。

相关问题