ComponentOne Bitmap for WPF
Features / Applying Transformations / Flipping an Image
In This Topic
    Flipping an Image
    In This Topic

    Bitmap lets you flip an image vertically as well as horizontally. To produce a flipped image using Bitmap, you can set the TransformOptions property of the FlipRotator class. The TransformOptions property can be set through TransformOptions enumeration in code.

    The image below shows a horizontally-flipped image.

     

    The following code illustrates flipping an image vertically or horizontally on button clicks. This example uses the sample created in the Quick start section.

    Private Sub ApplyTransform(t As BaseTransform)
        Dim newBitmap = bitmap.Transform(t)
        bitmap.Dispose()
        bitmap = newBitmap
        UpdateImage()
    End Sub
    
    'Event to flip the image vertically on button click
    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        ApplyTransform(New FlipRotator(TransformOptions.FlipVertical))
    End Sub
    
    'Event to flip the image horizontally on button click
    Private Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
        ApplyTransform(New FlipRotator(TransformOptions.FlipHorizontal))
    End Sub
    
    void ApplyTransform(BaseTransform t)
    {
        var newBitmap = bitmap.Transform(t);
        bitmap.Dispose();
        bitmap = newBitmap;
        UpdateImage();
    }
    
    //Event to flip the image vertically on button click
    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        ApplyTransform(new FlipRotator(TransformOptions.FlipVertical));
    }
    
    //Event to flip the image horizontally on button click
    private void Button_Click_2(object sender, RoutedEventArgs e)
    {
        ApplyTransform(new FlipRotator(TransformOptions.FlipHorizontal));
    }
    
    See Also