【问题标题】:Image Flipping in WPFWPF中的图像翻转
【发布时间】:2009-08-20 21:09:04
【问题描述】:

如何在不使用 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 的列表。 这真的很简单,但我似乎无法弄清楚如何去做。请帮忙。

【问题讨论】:

    标签: wpf reflection image


    【解决方案1】:

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

    例如,in this article.

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

    【讨论】:

      猜你喜欢
      • 2011-03-01
      • 2011-08-02
      • 1970-01-01
      • 2019-01-26
      • 2012-01-14
      • 2017-06-24
      • 2013-07-01
      • 2015-05-08
      • 1970-01-01
      相关资源
      最近更新 更多