ImageEn, unit imageenproc

TImageEnProc.Crop

TImageEnProc.Crop


Declaration

// Standard overload
procedure Crop(x1, y1, x2, y2 : Integer);

// TRect overload
procedure Crop(Rect : TRect);

// TRect with rotation overload
procedure Crop(Rect: TRect; Rotation: double; AntialiasMode: TIEAntialiasMode = ierFast);

// Perspective fix overload
procedure Crop(Quadrilater: array of TDPoint); overload;


Description

Replace the current image with that within the specified rectangle (i.e. keep only the specified region).

The Perspective fix overload allows you to adjust images that have perspective distortion. You need to specify the four points that will become the corners of the new image. The order is as follows:
- Top-Left corner
- Top-right corner
- Bottom-right corner
- Bottom-Left corner



Notes:
- Negative or out-of-range values will enlarge the image
- Use CropSel to crop to the current selection


Examples

// Crop the image at position, Top-Left: (20, 20), Bottom-right: (100, 100). The resulting image will be 80 x 80 pixels
ImageEnView1.Proc.Crop( 20, 20, 100, 100 );

// Crop to the selected area of the image (same as ImageEnView1.Proc.CropSel)
ImageEnView1.Proc.Crop( ImageEnView1.SelectedRect.x,
                        ImageEnView1.SelectedRect.y,
                        ImageEnView1.SelectedRect.x + ImageEnView1.SelectedRect.Width,
                        ImageEnView1.SelectedRect.y + ImageEnView1.SelectedRect.Height );

// Rotate an image 20 deg. CCW and crop 100 pixels from each side
ImageEnView1.Proc.Crop( Rect( 100, 100, ImageEnView1.IEBitmap.Width - 100, ImageEnView1.IEBitmap.Height - 100 ),
                        20, ierBicubic );

// Crops to the specified quadrilateral (4 points that will become the new corners) and applies forward perspective mapping. Useful to adjust perspective distortion
ImageEnView1.Proc.Crop([ DPoint(104, 85), // Top-Left corner
                         DPoint(1000, 150), // Top-right corner
                         DPoint(181, 500), // Bottom-right corner
                         DPoint(54, 400) // Bottom-Left corner
                        ]);

// Fix a parallelogram
ImageEnView1.Proc.Crop([ DPoint(50, 0), DPoint(500, 0), DPoint(450, 400), DPoint(0, 400)]);




See Also

- CropSel
- Global Image Methods