Reputation: 929
trying to rotate a bitmapImage 90 degrees but have been unable so far.
doesn't actually work. TransformedBitmap type does not exist and and BitmapImage has no .beginInit() and .EndInit() methods
I already have added
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
have MS forgot to update their documentation, am I doing something wrong or is this actually not meant for Windows 8?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaptransform.aspx I also found this but were unable to find an example of using it.
Upvotes: 1
Views: 1374
Reputation: 929
http://msdn.microsoft.com/en-us/library/windows/apps/jj709937.aspx
this as suggested by Mihai Hantea ended up doing the trick. Turns out I was missing an Await command on a .FlushAsync(). After addding the await it suddenly came together and worked brilliantly.
Upvotes: 0
Reputation: 1347
Maybe this can help in your situation:
Code-Behind:
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);
Upvotes: 0
Reputation: 956
The TransformedBitmap type does exist. But you have to add a reference to you project to PresentationCore.dll
Then follow this example: http://msdn.microsoft.com/en-us/library/aa970271(v=vs.110).aspx
(Stolen from the link)
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()
Upvotes: 1