Rotate a BitmapImage

后端 未结 2 1022
南笙
南笙 2021-01-14 07:24

I want to rotate a bitmap image I wrote some code and it work

TransformedBitmap TempImage = new TransformedBitmap();

TempImage.BeginInit();
TempImage.Sourc         


        
相关标签:
2条回答
  • 2021-01-14 07:28

    How about this:

    BitmapImage image = new BitmapImage();
    image.BeginInit();
    image.CacheOption = BitmapCacheOption.OnLoad;
    image.UriSource = new Uri(ImagePath);
    
    // here
    image.Rotation = Rotation.Rotate270; // or 90, 0, 180
    
    image.EndInit();
    
    0 讨论(0)
  • 2021-01-14 07:53

    How about this?

    var transformBitmap = (TransformedBitmap)image1.Source;
    RotateTransform rotateTransform = (RotateTransform)(transformBitmap.Transform);
    rotateTransform.Angle += 90;
    image1.Source = transformBitmap.Clone();
    
    0 讨论(0)
提交回复
热议问题