ImageEn, unit imageenproc |
|
TImageEnProc.CropSel
Declaration
procedure CropSel(TransparencyOnly: Boolean = False; FillColor: TColor = clNone);
Description
Removes all parts of the image outside the selected region (the image will become the size of the selection).
When TransparencyOnly is true only the alpha channel is cropped, i.e. areas outside the selection are marked as transparent in the alpha channel (the image size does not change).
If FillColor is clNone, the removed area will become transparent (if the image has an
AlphaChannel), otherwise the alpha is merged with the specified color.
Note:
◼Use
ClearSel to remove the area within the selection.
◼Use
Crop to crop using code
| Demos\ImageEditing\SelectAndCrop\ImageEn_Crop.dpr |
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
// Crop the image at the bitmap position, Top-Left: (150, 100), Bottom-right: (450, 300). The resulting image will be 300 x 200 pixels
ImageEnView1.SelectionBase := iesbBitmap;
ImageEnView1.Select( 150, 100, 300, 200 );
ImageEnView1.Proc.CropSel();
// Which is the same as...
ImageEnView1.Proc.Crop( rect( 150, 100, 300, 200 ) );
// And also the same as...
ImageEnView1.Proc.Crop( 20, 20, 100, 100 );
// Perform a Photoshop like crop (image is not cropped at all, the areas outside the crop rect are marked as transparent)
ImageEnView1.Select(10, 10, 100, 100);
ImageEnView1.Proc.CropSel(true);
// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );
// Make circular selection of entire image and crop
ImageEnView1.SelectionBase := iesbBitmap;
ImageEnView1.SelectEllipse(ImageEnView1.IEBitmap.Width div 2,
ImageEnView1.IEBitmap.Height div 2,
ImageEnView1.IEBitmap.Width,
ImageEnView1.IEBitmap.Height);
ImageEnView1.AlphaChannel; // Ensure we have an alpha channel so removed area becomes transparent
ImageEnView1.Proc.CropSel();