0

I'm extremely new to WPF and I'm trying to figure out how it works... I currently have a canvas (ScrollViewer) that has an image shown on it. How do I rotate the image 90 degrees so that when I save it, it is saved at the 90 degree rotation?

I currently have the following...

private void BtnRotate_Click(object sender, RoutedEventArgs e)
{
    RotateTransform rotateTransform = svImg.LayoutTransform as RotateTransform;
    if (rotateTransform == null)
    {
        rotateTransform = new RotateTransform(90, 0, 0);
        svImg.LayoutTransform = rotateTransform;
    }
    else
    {
        rotateTransform.Angle += 90;
    }

    svImg.VerticalAlignment = VerticalAlignment.Top;
    svImg.HorizontalAlignment = HorizontalAlignment.Left;
}

But this only rotates the canvas. The image itself is still oriented the same way so when it's saved it does not have the rotation change on the new image.

Anyone know an easy way to rotate my image in the ScrollViewer?

Arvo Bowen
  • 4,524
  • 6
  • 51
  • 109
  • Rotating the ScrollViewer will not change your image data. Can you try [this helper class](https://stackoverflow.com/questions/6222053/problem-reading-jpeg-metadata-orientation/38459903#38459903) and see if changing the EXIF data of your image saves the image correctly? – Roger Leblanc Jan 03 '18 at 00:00
  • Thanks @RogerLeblanc how can I go about using that on the ScrollViewer? I don't have any type of file (such as a jpg or tiff image) to use. I guess I could alter `RotateImageByExifOrientationData(string sourceFilePath, string targetFilePath, ImageFormat targetFormat, bool updateExifData = true)` a little to just let me use a bmp as the source but then I need to get it back to the ScrollViewer canvas. Any way you might be able to post an answer with an example NOT using anything but a ScrollViewer (no file)? – Arvo Bowen Jan 03 '18 at 01:31

0 Answers0