BitmapImage.Rotation Eigenschaft

Definition

Ruft den Winkel für die Drehung des BitmapImage ab oder legt diesen fest.

public:
 property System::Windows::Media::Imaging::Rotation Rotation { System::Windows::Media::Imaging::Rotation get(); void set(System::Windows::Media::Imaging::Rotation value); };
public System.Windows.Media.Imaging.Rotation Rotation { get; set; }
member this.Rotation : System.Windows.Media.Imaging.Rotation with get, set
Public Property Rotation As Rotation

Eigenschaftswert

Rotation

Die Drehung, die für das BitmapImage verwendet wird. Der Standardwert ist Rotate0.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie Sie ein Bild mithilfe von Extensible Application Markup Language (XAML) und Code drehen.

<Image Width="150" Margin="5" Grid.Column="0" Grid.Row="1">
  <Image.Source>
    <TransformedBitmap Source="/sampleImages/watermelon.jpg" >
      <TransformedBitmap.Transform>
        <RotateTransform Angle="90"/>
      </TransformedBitmap.Transform>
    </TransformedBitmap>
  </Image.Source>
</Image>
// Create Image element.
Image rotated90 = new Image();
rotated90.Width = 150;

// Create the TransformedBitmap to use as the Image source.
TransformedBitmap tb = new TransformedBitmap();

// Create the source to use as the tb source.
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(@"sampleImages/watermelon.jpg", UriKind.RelativeOrAbsolute);
bi.EndInit();

// Properties must be set between BeginInit and EndInit calls.
tb.BeginInit();
tb.Source = bi;
// Set image rotation.
RotateTransform transform = new RotateTransform(90);
tb.Transform = transform;
tb.EndInit();
// Set the Image source.
rotated90.Source = tb;
' Create Image element.
Dim rotated90 As New Image()
rotated90.Width = 150

' Create the TransformedBitmap to use as the Image source.
Dim tb As New TransformedBitmap()

' Create the source to use as the tb source.
Dim bi As New BitmapImage()
bi.BeginInit()
bi.UriSource = New Uri("sampleImages/watermelon.jpg", UriKind.RelativeOrAbsolute)
bi.EndInit()

' Properties must be set between BeginInit and EndInit calls.
tb.BeginInit()
tb.Source = bi
' Set image rotation.
Dim transform As New RotateTransform(90)
tb.Transform = transform
tb.EndInit()
' Set the Image source.
rotated90.Source = tb

Hinweise

Die Drehung wird nach der Skalierung ausgeführt. Dies bedeutet, dass ein Bild, das eine Rotation von , DecodePixelWidth eine von 10 und 5 hat, zu einem Bild führt, das eine Breite von Rotate905 und DecodePixelHeight eine Höhe von 10 aufweist.

Informationen zur Abhängigkeitseigenschaft

Bezeichnerfeld RotationProperty
Metadateneigenschaften auf true festgelegt Keine

Gilt für

Siehe auch