ClearImage .NET API
Crop(Rectangle) Method
Example 





Inlite.ClearImageNet Namespace > ImageEditor Class > Crop Method : Crop(Rectangle) Method
Cropping rectangle
Crops image to specified rectangular area
Syntax
'Declaration
 
Public Overloads Sub Crop( _
   ByVal r As System.Drawing.Rectangle _
) 
'Usage
 
Dim instance As ImageEditor
Dim r As System.Drawing.Rectangle
 
instance.Crop(r)
public void Crop( 
   System.Drawing.Rectangle r
)
public procedure Crop( 
    r: System.Drawing.Rectangle
); 
public function Crop( 
   r : System.Drawing.Rectangle
);
public:
void Crop( 
   System.Drawing.Rectangle r
) 

Parameters

r
Cropping rectangle
Remarks
Zone parameter does not apply
Example
void ImageMethods(string imageFile, string imageFileOut)
{
    ImageEditor editor = new ImageEditor();
    ImageEditor editorCenter = new ImageEditor();
    try
    {
        // Open image file
        editor.Image.Open(imageFile, 1);
        // Crop area of the image
        editor.Crop(100, 200, 800, 1000);
        // Convert to grayscale
        editor.ToGrayscale();
        // Create a zone in the upper left corner
        editor.Zone = new System.Drawing.Rectangle(0, 0, editor.Width / 2, editor.Height / 2);
        // Invert center area of the image
        editor.Clear();
        // Create a zone in the center of the image
        editor.Zone = new System.Drawing.Rectangle(editor.Width / 3, editor.Height / 3, editor.Width / 3, editor.Height / 3);
        // Invert center area of the image
        editor.Invert();
        // Duplicate center area to a new image
        editorCenter.Copy(editor);
        // Convert image to bi-tonal
        editorCenter.ToBitonal();
        //  Remove zone from the editor image
        editor.Zone = new System.Drawing.Rectangle();
        //  Save processed image
        editor.Image.SaveAs(imageFileOut, Inlite.ClearImage.EFileFormat.ciEXT);
    }
    catch (ClearImageException ex)
    { Console.WriteLine(ex.Message); }
    finally
    {
        editor.Dispose();  editorCenter.Dispose(); // ClearImage V9 and later
    }
}
See Also

Reference

ImageEditor Class
ImageEditor Members
Overload List