Skip to main content

TdxCustomSmartImage.Scale(Integer,Integer) Method

Resizes the stored image while keeping its aspect ratio.

Declaration

procedure Scale(const M: Integer; const D: Integer);

Parameters

Name Type Description
M Integer

The multiplier of the scale factor applied to the stored image. If the multiplier is higher than the denominator, the procedure upscales the image.

D Integer

The denominator of the scale factor applied to the stored image. If the denominator is higher than the multiplier, the procedure downscales the image.

Remarks

Call the Scale procedure to upscale or downscale the stored image while keeping its height-to-width ratio. To upscale or downscale the stored image to specific dimensions, call one of the overloaded Resize procedures instead.

Note

If the stored image is in any supported raster format, the Scale procedure converts the image into the BMP format and discards the original image metadata. You can use the ImageCodec property to convert the stored image to the original format.

You can scale SVG images without changing their format.

Example

The following code example downscales the stored image to two-thirds of its original dimensions:

var
  AImage: TdxSmartImage;
  dxOpenPictureDialog1: TdxOpenPictureDialog;
  //...
  dxOpenPictureDialog1.Execute(Handle);
  if(dxOpenPictureDialog1.FileName = '') then Exit;
  AImage := TdxSmartImage.Create;
  AImage.LoadFromFile(dxOpenPictureDialog1.FileName);
  AImage.Scale(2, 3);
See Also