Click or drag to resize

BitmapExtensionsResize(Image, Size, Boolean) Method

Returns a resized Bitmap image of the original.

Namespace: GSF.Drawing
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax
public static Bitmap Resize(
	this Image originalImage,
	Size newSize,
	bool disposeOriginal
)
View Source

Parameters

originalImage  Image
The original Bitmap image to be resized.
newSize  Size
The Size to which the original image is to be resized.
disposeOriginal  Boolean
true if the original image is to be disposed after resizing it; otherwise false.

Return Value

Bitmap
A Bitmap instance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Example
This example shows how to resize an image and dispose the original image that was resized:
C#
using System;
using System.Drawing;
using GSF.Drawing;

class Program
{
    static void Main(string[] args)
    {
        // Load original, resize it, and dispose original.
        using (Bitmap resized = ((Bitmap)Bitmap.FromFile("Original.jpg")).Resize(new Size(800, 600), true))
        {
            // Save the resized image to file.
            resized.Save("OriginalResized.jpg");
        }

        Console.ReadLine();
    }
}
See Also