crop()

Description

Crops an image of the specified index in buffer.

Syntax

ImageViewerObject.image.crop(index, left, top, right, bottom);

Parameters

<int> index: specifies the index of image in buffer. The index is 0-based.
<int> left: specifies the x-coordinate of the upper-left corner of the rectangle. The unit is pixel.
<int> top: specifies the y-coordinate of the upper-left corner of the rectangle. The unit is pixel.
<int> right: specifies the x-coordinate of the lower-right corner of the rectangle. The unit is pixel.
<int> bottom: specifies the y-coordinate of the lower-right corner of the rectangle. The unit is pixel.

Return value

bool

true indicates success. false indicates failure.

Example

if (DCSObject) {
    var imageviewer = DCSObject.getImageViewer("ImageViewerContainer");
    imageviewer.image.crop(0, 0, 0, 300, 400);
}

Remarks

crop() crops an image and replaces the original image with the cropped copy. If the application still needs the original image, use copyToImageViewer() instead.

If the value of left or top is negative, it will be treated as zero.

If the value of right is larger than the width of image, it will be treated as the width of image.

If the value of bottom is larger than the height of image, it will be treated as the height of image.

The value of left must be smaller than the value of right and the value of right must be positive.

The value of top must be smaller than the value of bottom and the value of bottom must be positive.

When false is returned, check getErrorCode() or getErrorString() for error information.

See Also

.image.copyToImageViewer()
.ui.getImageSelectedAreaInfo()

Is this page helpful?

Leave a Reply

Your email address will not be published.