Cropping and zooming
Cropping
It is possible to easily define an area of the video source that will be cropped.
- define a cropping size with Cropping_Width and Cropping_Height,
- enable the cropping with Cropping_Enabled,
- start the preview, recording or playback,
- now it is possible to move the cropping area (even dynamically during preview, recording or playback) with Cropping_X and Cropping_Y.
Trackbar bounds
When trackbars are used to move the cropped area over the video window, the maximum positions for these trackbars are returned by the Cropping_XMax and Cropping_YMax properties.
The best location to update the trackbar bounds is from the OnResizeVideo event. E.g.:
procedure TForm1.VideoGrabberResizeVideo(Sender: TObject; SourceWidth, SourceHeight: Integer);
begin
TrackBarX.Min:= 0;
TrackBarX.Position:= VideoGrabber.Cropping_X;
TrackBarX.Max:= VideoGrabber.Cropping_XMax;
TrackBarY.Min:= 0;
TrackBarY.Position:= VideoGrabber.Cropping_Y;
TrackBarY.Max:= VideoGrabber.Cropping_YMax;
end;
Zooming
It is possible to zoom a cropped area as follows:
- define a cropping size with Cropping_Width and Cropping_Height,
- enable the cropping with Cropping_Enabled,
- start the preview, recording or playback,
- now it is possible to dynamically specify a zooming coefficient with Cropping_Zoom,
- it is also possible to move the cropping area with Cropping_X and Cropping_Y.
Note: if the zooming area is near an edge of the video frame, when changing Cropping_Zoom, the video image will "move" in the opposite direction.
To prevent this problem, enable the Cropping_Outbounds property. This will keep the zooming location fixed against the edges, however, as a trade-off, a black border will appear when Cropping_X and Cropping_Y are near the edges.