ImageEn, unit iexBitmaps

TIEBitmap.AutoCrop

TIEBitmap.AutoCrop


Declaration

function AutoCrop(Tolerance: Integer; Background: TColor; CropThreshold: Double = 0.0): TRect;


Description

Remove any bordering area of an image of a certain color.
If Background is clNone then transparent boundaries of the image will be cropped (using CropAlpha).

Parameter Description
Tolerance How closely we match the color to Background (0 to 255, where 0 matches only the specified color, and 255 would remove everything)
Background The border color to remove
CropThreshold The minimum percentage of border color within a row/column to consider that it has content area, e.g. For 0.01, if more than 1% of pixels are background color then the row/column will be included. Higher values make the crop more aggressive, i.e. some content may be lost. Typical values are 0.001 - 0.02

Returns the area that was cropped.
If a border is not found the result will be a rect of (0, 0, w-1, h-1).

Note: AutoCrop() does not consider the alpha channel except when Background is clNone