ProjectiveTransform

function ProjectiveTransform(img: TImage32; const srcPts, dstPts: TPathD; const margins: TRect): Boolean;


Projective transformations will preserve lines within images, but not parallelism.

A projective transformation is accomplished by aligning four points in one projectve (source) with four corresponding points in the new projective (destination). However, the function will only succeed if these points describe convex quadrilaterals.

If srcPts are inside the image, then margins will expand the view of new projectve by these margins (and relative to this new projective). However, when srcPts represents the image bounds of the starting projective, then the margins parameter will be ignored.


  uses Image32, Image32_PNG, 
    Image32_Vector, Image32_Transform;
  ...
var
  img: TImage32;
  src, dst: TPathD;
begin
  img := TImage32.Create;
  img.LoadFromFile('clouds.png');
  
  //setup the transformation geometry
  src := Rectangle(src.Bounds); 
  dst := src;
  dst[0].Y := 20;
  dst[3].Y := img.Height-20; 
  
  //transform and save
  ProjectiveTransform(img, src, dst, nullRect);
  img.SaveToFile('clouds_proj.png');
  img.Free;
end;