ComponentOne Bitmap for UWP
Flipping an Image
Features > Applying Transformations > Flipping an Image

Flipping is creating a mirror image of the original image, vertically or horizontally. Bitmap allows both, flipping an image horizontally as well as vertically, using the TransformOptions property of the FlipRotator class. The TransformOptions property accepts value from the TransformOptions enum to set the transformation options.

The image given below shows a horizontally flipped image.

 

The following code implements flipping on an image horizontally on a button's click event. This example uses the sample created in the Quick Start.

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 btnFlip_Click(sender As Object, e As RoutedEventArgs)
    Await ApplyTransform(New FlipRotator(TransformOptions.FlipHorizontal))
End Sub
private async Task ApplyTransform(BaseTransform t)
{
    var bm = btmp.Transform(t);
    btmp.Dispose();
    btmp = bm;
    await UpdateImageSource();
}

private async void btnFlip_Click(object sender, RoutedEventArgs e)
{
    await ApplyTransform(new FlipRotator(TransformOptions.FlipHorizontal));
}

Similarly, you can flip an image vertically using FlipVertical value of the TransformOptions enum.

See Also