|
BitmapExtensionsCrop(Image, Rectangle, Boolean) Method
|
Returns a cropped
Bitmap image of the original.
Namespace: GSF.DrawingAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.282-beta+fbfa6baa1521236175f6d73fb2eb151a42453aef
SyntaxGSF.Drawing.BitmapExtensions.Crop = function(originalImage, croppedArea, disposeOriginal);
View SourceParameters
- originalImage Image
- The original Bitmap image to be cropped.
- croppedArea Rectangle
- The Rectangle area of the original image to be cropped.
- disposeOriginal Boolean
- true if the original image is to be disposed after cropping it; otherwise false.
Return Value
BitmapA
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 crop an image and dispose the original image that was cropped:
using System;
using System.Drawing;
using GSF.Drawing;
class Program
{
static void Main(string[] args)
{
// Load original, crop it, and dispose original.
using (Bitmap cropped = ((Bitmap)Bitmap.FromFile("Original.jpg")).Crop(new Rectangle(0, 0, 300, 300), true))
{
// Save the cropped image to file.
cropped.Save("OriginalCropped.jpg");
}
Console.ReadLine();
}
}
See Also