# Scaling an Image

## Content

Scaling is an important requirement of image processing as it resizes (increases and decreases the size) image. Bitmap also allows scaling in and out an image through the [InterpolationMode](/componentone/api/wpf/online-bitmap/dotnet-framework-api/C1.WPF.Bitmap.4.6.2/C1.WPF.Bitmap.Scaler.InterpolationMode.html) property of the [Scaler](/componentone/api/wpf/online-bitmap/dotnet-framework-api/C1.WPF.Bitmap.4.6.2/C1.WPF.Bitmap.Scaler.html) class.

The image below shows scaling in and scaling out feature.

![](https://cdn.mescius.io/document-site-files/images/32d5893e-4934-4c4a-b98e-8ae7ac6c66ba/images/bitmap-scaling.gif)

The following code illustrates scaling in and scaling out an image on button clicks. This example uses the sample created in the [Quick start](/componentone/docs/wpf/online-bitmap/QuickStart).

```vbnet
Private Sub ApplyTransform(t As BaseTransform)
    Dim newBitmap = bitmap.Transform(t)
    bitmap.Dispose()
    bitmap = newBitmap
    UpdateImage()
End Sub
'Event to scale in the image on button click
Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
    Dim px As Integer = CInt(bitmap.PixelWidth * 0.625F + 0.5F)
    Dim py As Integer = CInt(bitmap.PixelHeight * 0.625F + 0.5F)
    If px > 0 AndAlso py > 0 Then
        ApplyTransform(New Scaler(px, py, InterpolationMode.HighQualityCubic))
    End If
End Sub
'Event to scale out the image on button click
Private Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
    Dim px As Integer = CInt(bitmap.PixelWidth * 1.6F + 0.5F)
    Dim py As Integer = CInt(bitmap.PixelHeight * 1.6F + 0.5F)
    ApplyTransform(New Scaler(px, py, InterpolationMode.HighQualityCubic))
End Sub
```

```csharp
void ApplyTransform(BaseTransform t)
{
    var newBitmap = bitmap.Transform(t);
    bitmap.Dispose();
    bitmap = newBitmap;
    UpdateImage();
}
//Event to scale in the image on button click 
private void Button_Click_1(object sender, RoutedEventArgs e)
{
    int px = (int)(bitmap.PixelWidth * 0.625f + 0.5f);
    int py = (int)(bitmap.PixelHeight * 0.625f + 0.5f);
    if (px > 0 && py > 0)
    {
        ApplyTransform(new Scaler(px, py, InterpolationMode.HighQualityCubic));
    }
}
//Event to scale out the image on button click
private void Button_Click_2(object sender, RoutedEventArgs e)
{
    int px = (int)(bitmap.PixelWidth * 1.6f + 0.5f);
    int py = (int)(bitmap.PixelHeight * 1.6f + 0.5f);
    ApplyTransform(new Scaler(px, py, InterpolationMode.HighQualityCubic));
}
```

## See Also

[Clipping an Image](/componentone/docs/wpf/online-bitmap/Features/ApplyingTransformations/ClippingImage)

[Flipping an Image](/componentone/docs/wpf/online-bitmap/Features/ApplyingTransformations/FlippingImage)

[Rotating an Image](/componentone/docs/wpf/online-bitmap/Features/ApplyingTransformations/RotatingImage)