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

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

    The image below shows a horizontally-flipped image. 

    Horizontally flip an image using ComponentOne Bitmap for WinForms

    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
        selection = New RectF(1.0F, 1.0F)
        UpdateImage()
    End Sub
    
    'Event to flip the image vertically on button click
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ApplyTransform(New FlipRotator(TransformOptions.FlipVertical))
    End Sub
    
    'Event to flip the image horizontally on button click
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ApplyTransform(New FlipRotator(TransformOptions.FlipHorizontal))
    End Sub
    
    void ApplyTransform(BaseTransform t)
    {
        var newBitmap = bitmap.Transform(t);
        bitmap.Dispose();
    
        bitmap = newBitmap;
        selection = new RectF(1f, 1f);
    
        UpdateImage();
    }
            
    //Event to flip the image vertically on button click
    private void button3_Click(object sender, EventArgs e)
    {
        ApplyTransform(new FlipRotator(TransformOptions.FlipVertical));
    }
    
    //Event to flip the image horizontally on button click
    private void button4_Click(object sender, EventArgs e)
    {
        ApplyTransform(new FlipRotator(TransformOptions.FlipHorizontal));
    }
    
    See Also