ImageEn, unit ImageEnView

TImageEnView.Zoom

TImageEnView.Zoom

Declaration

property Zoom: Double;

Description

Use the Zoom property to zoom in or out of the image. The image itself is not modified, only its display size changes.
Zoom is expressed as a percentage of its native size, i.e. 100 is normal size, values less than 100 decrease the display size and values greater than 100 increase the display size.

Note:
◼Zoom will only have a temporary effect if AutoShrink or AutoStretch is enabled, unless you add iedoDisableAutoFitWhenZoom to DisplayOptions
◼Use ZoomFilter to improve the quality when zooming
◼By default, scrolling the mouse wheel will zoom the view. You can limit the bounds of the zoom using OnZoomIn and OnZoomOut
◼If mkiMiscellaneous is defined for KeyInteract, clicking Ctrl+Plus/Minus will zoom in/out of the image. Ctrl+0 will reset the zoom

Default: 100

Examples

// Half size: a 200x200 pixel image is displayed at a size of 100x100
ImageEnView.Zoom := 50;


// Double size: a 200x200 pixel image is displayed at a size of 400x400
ImageEnView.Zoom := 200;


// Floating point zoom
ImageEnView.Zoom := 30.25;


// Show image zoom based on its DPI
// Note: More accurately you should get the PPI for the display monitor (e.g. Form.CurrentPPI)
Caption := IntToStr( Round( ImageEnView1.Zoom / ImageEnView1.IO.Params.Dpi * Screen.PixelsPerInch )) + '%';


// Display image at 100% based on its DPI
// Note: More accurately you should get the PPI for the display monitor (e.g. Form.CurrentPPI)
ImageEnView1.Zoom := ImageEnView1.IO.Params.Dpi / Screen.PixelsPerInch * 100;


// Toggle auto-shrink when pressing the space key
procedure TForm1.ImageEnView1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_SPACE then
  begin
    ImageEnView1.AutoShrink := not ImageEnView1.AutoShrink;
    if not ImageEnView1.AutoShrink then
      ImageEnView1.Fit()
    else
      ImageEnView1.Zoom := 100;
  end;
end;


// Allow a user to zoom the image or toggle between 100% or Zoom-to-Fit
// Controls:
//   - lblZoom: TLabel with Caption of 'Zoom'
//   - chkFit: TCheckbox with Caption o 'Fit'
//   - trkZoom: TTrackBar with Min = 1, Max = 500, Position = 100
// chkFit.OnClick, trkZoom.OnChange and ImageEnView1.OnResize should all point to the following event:
procedure TMainForm.trkZoomChange(Sender: TObject);
begin
  if ( Sender = chkFit ) and not chkFit.Checked then
  begin
    ImageEnView1.Zoom := 100;
    trkZoom.Position  := 100;
  end
  else
  if ( Sender <> trkZoom ) and chkFit.Checked then
  begin
    trkZoom.Position := Trunc(ImageEnView1.GetIdealZoom);
    ImageEnView1.Fit();
  end
  else
  if trkZoom.Position <> Trunc(ImageEnView1.GetIdealZoom) then
  begin
    ImageEnView1.Zoom := trkZoom.Position;
    chkFit.Checked := False;
  end;
end;

See Also

◼ZoomX
◼ZoomY
◼ZoomIn
◼ZoomOut
◼OnZoomIn
◼OnZoomOut