Bitmap for UWP
画像の回転
機能 > 変換の適用 > 画像の回転

Bitmap は、画像を時計回りに90度、180度、270度の異なる角度に回転させる柔軟性を提供します。C1Bitmap によって提供される FlipRotator クラスの TransformOptions プロパティを使用して画像を回転することができます。TransformOptions プロパティは、変換オプションを設定するために TransformOptions 列挙値を受け入れます。

以下の画像は、時計回りに180度回転した画像を示しています。

以下のコードは、ボタンのクリックイベントにて画像を時計回りに180度回転する処理を実装します。この例では、「クイックスタート」セクションで作成したサンプルを使用します。

Private Async Function UpdateImageSource() As Task
    Dim sb As SoftwareBitmap = btmp.ToSoftwareBitmap()
    Await sbs.SetBitmapAsync(sb)
    img.Source = sbs
End Function

Private Async Function ApplyTransform(t As BaseTransform) As Task
    Dim bm = btmp.Transform(t)
    btmp.Dispose()
    btmp = bm
    Await UpdateImageSource()
End Function

Private Async Sub btnRotate_Click(sender As Object, e As RoutedEventArgs)
    Await ApplyTransform(New FlipRotator(TransformOptions.Rotate180))
End Sub
private async Task ApplyTransform(BaseTransform t)
{
    var bm = btmp.Transform(t);
    btmp.Dispose();
    btmp = bm;
    await UpdateImageSource();
}

private async void btnRotate_Click(object sender, RoutedEventArgs e)
{
    await ApplyTransform(new FlipRotator(TransformOptions.Rotate180));
    
}
関連トピック