试图将bitmapImage旋转90度,但到目前为止还没有。
实际上并不起作用。 TransformedBitmap类型不存在,并且BitmapImage没有.beginInit()和.EndInit()方法
我已添加
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
MS忘记更新他们的文档,我做错了什么或者这实际上不适用于Windows 8?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaptransform.aspx 我也找到了这个,但无法找到使用它的例子。
答案 0 :(得分:0)
TransformedBitmap类型确实存在。但您必须将项目引用添加到PresentationCore.dll
然后按照此示例:http://msdn.microsoft.com/en-us/library/aa970271(v=vs.110).aspx
(从链接中窃取)
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg");
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
TransformedBitmap myRotatedBitmapSource = new TransformedBitmap();
myRotatedBitmapSource.BeginInit();
myRotatedBitmapSource.Source = myBitmapImage;
myRotatedBitmapSource.Transform = new RotateTransform(90);
myRotatedBitmapSource.EndInit()
答案 1 :(得分:0)
也许这对你的情况有帮助:
代码隐藏:
var image = new Image
{
Height = 50,
Width = 50,
RenderTransform = new RotateTransform()
{
Angle = 90,
CenterX = 25, //The prop name maybe mistyped
CenterY =25 //The prop name maybe mistyped
},
Source = new BitmapImage(new Uri("MyImageSoruce"))
};
MainGrid.Children.Add(image);
答案 2 :(得分:0)
http://msdn.microsoft.com/en-us/library/windows/apps/jj709937.aspx
按照Mihai Hantea的建议最终做了这个伎俩。事实证明我在.FlushAsync()上缺少Await命令。在添加等待之后,它突然聚集在一起并且运行得非常出色。