我有一个可观察的BitmapImage类型集合,在其中存储一些图像,这个集合被绑定到UI。
现在的问题是,我想要改变这些图像,例如旋转。现在为了旋转,我必须用TransformedBitmap做一个BitmapImages,这不是问题。
当我完成的时候,我想把它们放回收藏品里,问题来了。
不能隐式地将类型'System.Windows.Media.Imaging.TransformedBitmap‘转换为“System.Windows.Media.Imaging.BitmapImage”
我找了很长很长时间,找不到解决这个问题的办法。
问题:如何将TransformedBitmap转换回BitmapImage?
发布于 2015-10-07 18:13:33
要在UI中绑定图像控件的Source属性,只需使用BitmapSource (甚至ImageSource)作为ObservableCollection的元素类型即可。
然后可以添加任何派生位图类型:
public ObservableCollection<BitmapSource> Bitmaps { get; set; }
...
Bitmaps.Add(new BitmapImage(new Uri(...)));
Bitmaps.Add(new TransformedBitmap(Bitmaps[0], new RotateTransform(90)));https://stackoverflow.com/questions/32990426
复制相似问题