SplineVertTransform

function SplineVertTransform(img: TImage32; const topSpline: TPathD; splineType: TSplineType; backColor: TColor32; reverseFill: Boolean; out offset: TPoint): Boolean;


Deforms an image in the vertical plane. 'topSpline' control points (either FlattenQSpline or FlattenCSpline points) define the top (curved) edge of the transformed image.

'backColor' and 'reverseFill' are only meaningful when the splines induce image overlap (see Example 2 below). Normal rendering is from top to bottom unless reverseFill = true, in which case rendering will be from bottom to top. If 'backColor' = clNone32, then the image will be rendered on 'back' regions as if the image is double sided, otherwise 'back' regions will be filled with 'backColor'.

The returned 'offset', is the offset of the top-left corner of the transformed (and resized) image (using the same axes as the spline coordinates) so that the transformed image can easily be aligned with the supplied control points.


uses Image32, Image32_PNG, Image32_Transform;
  ...
var
  img: TImage32;
  topPath: TPathD;
  pt: TPoint;
begin
  img := TImage32.Create;
  img.LoadFromFile('union_jack.png');
  topPath := MakePathI([161,315,  221,309,  
    190,357,  248,367,  274,414,  326,415]);
  SplineVertTransform(img, topPath, stCubic, clNone32, false, pt);
  img.SaveToFile('wavy_flag.png');
  img.Free;
      
Before:
After:

uses Image32, Image32_PNG, Image32_Transform;
  ...
var
  img: TImage32;
  topPath, botPath: TPathD;
  pt: TPoint;
begin
  img := TImage32.Create;
  img.LoadFromFile('union_jack.png');
  topPath := MakePath([201,301, 451,335, 89,408, 401,401]);
  botpath := OffsetPath(topPath, 0, img.Height);
  SplineVertTransform(img, topPath, stCubic, clNone32, false, pt);
  img.SaveToFile('wavy_flag1.png');
  img.LoadFromFile('union_jack.png');
  SplineVertTransform(img, topPath, stCubic, clRed32, false, pt);
  img.SaveToFile('wavy_flag2.png');
  img.LoadFromFile('union_jack.png');
  SplineVertTransform(img, topPath, stCubic, clRed32, true, pt);
  img.SaveToFile('wavy_flag3.png');  
  img.Free;
      
'Transparent' background
Renders left-to-right
Colored background
Renders left-to-right
Colored background
Renders right-to-left

See Also

Image32_Layers, SplineHorzTransform, FlattenCSpline, FlattenQSpline, TSplineType