AffineTransform

procedure AffineTransform(img: TImage32; matrix: TMatrixD);


Affine transformations can be separated into 4 discrete operations - translation, rotation, skew (sometimes called shear) and scale. If just a single discrete operation is to be performed (eg scaling), then the corresponding TImage32 method will deliver the best image quality. However for complex affine transformations that combine several discrete operations, this function will definitely be faster than performing these operations separately.

The TImage32 object will resize automatically to accommodate the geometry of the new image.

uses Image32, Image32_PNG, Image32_Transform;
...
var
  img: TImage32;
  mat, mat2: TMatrixD;
  s,c: double;
begin
  img := TImage32.Create;
  img.LoadFromFile('beetle.png');
    
  mat := IdentityMatrix;
  //vertical skew
  mat[0, 1] := -0.5;
  //and rotation too
  SinCos(angle45, s, c);
  mat2 := IdentityMatrix;
  mat2[0, 0] := c;   mat2[1, 0] := s;
  mat2[0, 1] := -s;  mat2[1, 1] := c;
  mat := MultiplyMatrices(mat, mat2);

  AffineTransform(img, mat);

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