Zooming In on a Selection (Delphi 6.0)
Take the following steps to add code that lets you select an area with a mouse, and zoom in on the selected area.
1. |
Start with the project that you created in Loading and Displaying an Image. |
2. |
Handle the LEADRasterView1 control's OnMouseDown2 event, and code LEADRasterView1MouseDown2 as follows: |
procedure TForm1.LEADRasterView1MouseDown2 (Sender: TObject; Button,
Shift: Smallint; x, y: Integer);
begin
//Enable AutoRubberBand
LEADRasterView1.AutoRubberBand := True;
LEADRasterView1.MousePointer := 2;
end;
3. |
Handle the LEADRasterView1 OnRubberBand event, and code LEADRasterView1RubberBand procedure, as follows: |
procedure TForm1.LEADRasterView1RubberBand(Sender: TObject);
var
zoomleft: Integer;
zoomtop: Integer;
zoomwidth: Integer;
zoomheight: Integer;
begin
LEADRasterView1.MousePointer := 0;
//Zoom in on the selection.
zoomleft := Trunc (LEADRasterView1.RubberBandLeft);
zoomtop := Trunc (LEADRasterView1.RubberBandTop);
zoomwidth := Trunc (LEADRasterView1.RubberBandWidth);
zoomheight := Trunc (LEADRasterView1.RubberBandHeight);
//Zoom in on the rectangle defined by the rubberband
LEADRasterView1.ZoomToRect (zoomleft, zoomtop, zoomwidth, zoomheight);
LEADRasterView1.Refresh() ;
end;
4. |
Run your program to test it. |