c# - 如何垂直翻转位图图像

标签 c# wpf

我想垂直翻转 BitmapImage 作为原始图像的镜像。 这就是我所拥有的,但它旋转时不会翻转图像。

var tb = new TransformedBitmap();
BitmapImage bi = Type.Image.Clone();
tb.BeginInit();
tb.Source = bi;
var transform = new RotateTransform(180);
tb.Transform = transform;
tb.EndInit();

最佳答案

您应该使用 scaleTransform,而不是 Rotate。并将其 y 比例设置为 -1 以将其设置为镜像:

var transform = new ScaleTransform(1, -1, 0, 0);

参见 http://msdn.microsoft.com/en-us/library/aa348048.aspx

关于c# - 如何垂直翻转位图图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19763246/

相关文章:

c# - 更新语句有问题

c# - 我如何使用 REGEX 忽略某些内容

c# - 使用泛型和 'new' 修饰符隐藏父成员时的 C# 继承问题

c# - 如何在 C# WPF 中的 SQL Server 2012 中存储 Circle 的空间数据

wpf - 从 Catel WPF UserControl 中的 ResourceDictionary 中绑定(bind)

c# - 非托管内存分配给托管对象

c# - 如何对在C#中使用LINQ使用反射找到的属性进行排序?

c# - WPF MVVM 为什么使用 ContentControl + DataTemplate View 而不是直接的 XAML 窗口 View ?

c# - 处置 BitmapSource 的正确方法

C# 测试堆栈.White : sometimes unable to find button