AffineTransformImage

function AffineTransformImage(image: TImage32; matrix: TMatrixD): TPoint;


Affine transformations can be separated into 4 discrete operations - translation, rotation, skew (aka shear) and scale. However the power of matrix transformations is in its ability to combine any number of transformations into a single operation.

The image's Resampler property will determine the speed and quality of the transformation.

This function will resize and offset the image so that the entire transformation will be contained within the new image.

The function Result indicates the offset of new image's origin relative to the untransformed image's origin. (This can be helpful when repositioning layered images.)

uses Img32, Img32.Fmt.PNG, Img32.Transform;
...
var
  img: TImage32;
  mat: TMatrixD;
begin
  img := TImage32.Create;
  img.LoadFromFile('beetle.png');
    
  mat := IdentityMatrix;
  MatrixSkew(mat, 0, -0.5);
  MatrixRotate(mat, img.MidPoint, -angle45);
  AffineTransformImage(img, mat);

  img.SaveToFile('beetle_affine.png');
  img.Free;
end;
      


See Also

TLayeredImage32, TImage32.Resampler