Show / Hide Table of Contents

Практическое руководство. Поворот изображения

В этом примере показано, как повернуть изображение на 90 градусов с помощью Rotation свойство BitmapImage.

Пример

<Image Width="150" Margin="5" Grid.Column="0" Grid.Row="1">
   <Image.Source>
     <BitmapImage UriSource="/sampleImages/watermelon.jpg" Rotation="Rotate90" />
   </Image.Source>
</Image>
//Create Image element
Image rotated270 = new Image();
rotated270.Width = 150;

//Create source
BitmapImage bi = new BitmapImage();
//BitmapImage properties must be in a BeginInit/EndInit block
bi.BeginInit();
bi.UriSource = new Uri(@"pack://application:,,/sampleImages/watermelon.jpg");
//Set image rotation
bi.Rotation = Rotation.Rotate270;
bi.EndInit();
//set image source
rotated270.Source = bi;
Back to top Неофициальная документация по .NET на русском языке. Лицензия: CC-BY 4.0. Основано на документации по .NET с Microsoft Docs
Generated by DocFX