ClearImage .NET API
Crop Method (CiImage)
Example 





Inlite.ClearImage Namespace > CiImage Class : Crop Method
Crop rectangle
Syntax
'Declaration
 
Public Function Crop( _
   ByVal left As System.Integer, _
   ByVal top As System.Integer, _
   ByVal right As System.Integer, _
   ByVal bottom As System.Integer _
) As System.Integer
'Usage
 
Dim instance As CiImage
Dim left As System.Integer
Dim top As System.Integer
Dim right As System.Integer
Dim bottom As System.Integer
Dim value As System.Integer
 
value = instance.Crop(left, top, right, bottom)
public System.int Crop( 
   System.int left,
   System.int top,
   System.int right,
   System.int bottom
)
public function Crop( 
    left: System.Integer;
    top: System.Integer;
    right: System.Integer;
    bottom: System.Integer
): System.Integer; 
public function Crop( 
   left : System.int,
   top : System.int,
   right : System.int,
   bottom : System.int
) : System.int;
public:
System.int Crop( 
   System.int left,
   System.int top,
   System.int right,
   System.int bottom
) 

Parameters

left
top
right
bottom
Remarks
This method crops the image to the size of the cropping rectangle.  left, top define upper left corner coordinates of the cropping rectangle.  right, bottom define lower right corner of the cropping rectangle.   The coordinates should be valid (right greater than left and bottom greater than top
Example
void ImageMethods()
{
    CiServer ci = Inlite.ClearImageNet.Server.GetThreadServer();
    CiImage image = ci.CreateImage();
    // Initialize 3000 pixels by 2000 pixels RGB image. All pixels of new RGB image are black.  Default resolution is 1 dpi
    image.CreateBpp(3000, 2000, 24);
    // Change DPI to 200
    image.HorzDpi = 200; image.VertDpi = 200;
    // Crop area of the image
    image.Crop(100, 200, 800, 1000);
    // Initialize 8.5" by 11" bi-tonal image. All pixels of new Bi-tonal image are white.  Default resolution is 300 dpi
    // Image initialization closes and frees memory of the previously crated RGB image
    image.Create((int)(8.5 * 300), (int)(11.0 * 300));
    // Convert to grayscale
    image.ToGrayscale();
    // Create zone in the center of the image
    CiImage zoneCenter = image.CreateZone(image.Width / 3, image.Height / 3, image.Width * 2 / 3, image.Height * 2 / 3);
    // Invert center area of the image
    zoneCenter.Invert();
    // Re-define zone to upper left quadrant of the image
    CiRect rect = ci.CreateRect(0, 0, image.Width / 2, image.Height / 2);
    CiImage zoneCorner = image.CreateZoneRect(rect);
    // Clear corner area on the image
    zoneCorner.Clear();
    // Duplicate center area to a new image
    CiImage imageCenter = zoneCenter.Duplicate();
    // Copy from the original image
    CiImage imageCopy = ci.CreateImage();
    imageCopy.Copy(image);
    // Convert image to bi-tonal
    imageCopy.ToBitonal();
    // Clean-up. Free image memory
    image.Close();
    imageCenter.Close();
    imageCopy.Close();
}
Sub ImageMethods()
    Dim ci As CiServer = Inlite.ClearImageNet.Server.GetThreadServer()
    Dim image As CiImage = ci.CreateImage()
    '  Initialize 3000 pixels by 2000 pixels RGB image. All pixels of new RGB image are black.  Default resolution is 1 dpi
    image.CreateBpp(3000, 2000, 24)
    '  Change DPI to 200
    image.HorzDpi = 200 : image.VertDpi = 200
    '  Crop area of the image
    image.Crop(100, 200, 800, 1000)
    '  Initialize 8.5" by 11" bi-tonal image. All pixels of new Bi-tonal image are white.  Default resolution is 300 dpi
    '  Image initialization closes and frees memory of the previously crated RGB image
    image.Create(8.5 * 300, 11 * 300)
    '  Convert to grayscale
    image.ToGrayscale()
    '  Create zone in the center of the image
    Dim zoneCenter As CiImage = image.CreateZone(image.Width / 3, image.Height / 3,
            image.Width * 2 / 3, image.Height * 2 / 3)
    '  Invert center area of the image
    zoneCenter.Invert()
    '  Re-define zone to upper left quadrant of the image
    Dim rect As CiRect = ci.CreateRect(0, 0, image.Width / 2, image.Height / 2)
    Dim zoneCorner As CiImage = image.CreateZoneRect(rect)
    '  Clear corner area on the image
    zoneCorner.Clear()
    '  Duplicate center area to a new image
    Dim imageCenter As CiImage = zoneCenter.Duplicate()
    '  Copy from the original image
    Dim imageCopy As CiImage = ci.CreateImage()
    imageCopy.Copy(image)
    '  Convert image to bi-tonal
    imageCopy.ToBitonal()
    '  Clean-up. Free image memory
    image.Close()
    imageCenter.Close()
    imageCopy.Close()
End Sub
See Also

Reference

CiImage Class
CiImage Members