BitmapImage.Rotation プロパティ

定義

この BitmapImage が回転する角度を取得または設定します。

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

プロパティ値

Rotation

BitmapImage に使用される回転。 既定値は、Rotate0 です。

次のコード例は、拡張アプリケーション マークアップ言語 (XAML) とコードを使用してイメージを回転させる方法を示しています。

<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

注釈

回転はスケーリング後に実行されます。 つまり、a、aDecodePixelWidth、10、および DecodePixelHeight 5 のRotate90イメージRotationは、幅が 5、高さが 10 の画像になります。

依存プロパティ情報

識別子フィールド RotationProperty
メタデータのプロパティが次に設定されている true なし

適用対象

こちらもご覧ください