【发布时间】:2016-05-18 16:27:24
【问题描述】:
我打开了一个带有打开文件对话框的图像。
image.Source = new BitmapImage(new Uri(ofd.FileName));
然后我想旋转多少次,最后保存修改后的图像。问题是来自 MSDN 的代码:
var biOriginal = (BitmapImage)image.Source;
var biRotated = new BitmapImage();
biRotated.BeginInit();
biRotated.UriSource = biOriginal.UriSource;
biRotated.Rotation = Rotation.Rotate90;
biRotated.EndInit();
image.Source = biRotated;
我可以旋转图像,但只能旋转一次,并且无法保存旋转后的图像。
【问题讨论】:
-
Saving a BitmapImage 和 rotate by angle (或者如果您想要不止一次旋转,请在循环中重复您的代码)
-
由于异常无法像那样旋转无法将“System.Windows.Media.Imaging.BitmapImage”类型的对象转换为“System.Windows.Media.Imaging.TransformedBitmap”类型。