@@ -36,6 +36,29 @@ implementation
3636```
3737*)
3838
39+ (*
40+ EImageResizeAlgo
41+ ----------------
42+ ```
43+ enum(NEAREST_NEIGHBOUR, BILINEAR, LANCZOS, BOX, HAMMING, BICUBIC)
44+ ```
45+ The resampling filter used by `TImage.Resize`, from fastest to highest quality:
46+
47+ - `NEAREST_NEIGHBOUR`: No blending - fastest, but blocky. Good for pixel-art.
48+ - `BOX`: Simple averaging - cheap, mainly for downscaling.
49+ - `BILINEAR`: Fast and smooth, but a little soft.
50+ - `HAMMING`: A little sharper than bilinear.
51+ - `BICUBIC`: Smooth and sharp - a good default.
52+ - `LANCZOS`: Sharpest and highest quality, but the slowest.
53+
54+ 
55+ 
56+
57+ ```{note}
58+ This enum is scoped so use like `EImageResizeAlgo.BILINEAR`
59+ ```
60+ *)
61+
3962(*
4063TImage.Construct
4164----------------
@@ -654,8 +677,9 @@ procedure _LapeImage_ReplaceColorBinary2(const Params: PParamArray); LAPE_WRAPPE
654677TImage.Resize
655678-------------
656679```
657- function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer): TSimbaImage ;
680+ function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer): TImage ;
658681```
682+ Returns a new image resized to `NewWidth` by `NewHeight`, sampled with the given `Algo` filter (see `EImageResizeAlgo`). The original image is left unchanged.
659683*)
660684procedure _LapeImage_Resize1 (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
661685begin
@@ -666,50 +690,38 @@ procedure _LapeImage_Resize1(const Params: PParamArray; const Result: Pointer);
666690TImage.Resize
667691-------------
668692```
669- function TImage.Resize(Algo: EImageResizeAlgo; Scale: Single): TSimbaImage ;
693+ function TImage.Resize(Algo: EImageResizeAlgo; Scale: Single): TImage ;
670694```
695+ Resizes by a `Scale` factor instead of absolute dimensions - e.g. `0.5` halves the width and height and `2.0` doubles them.
671696*)
672697procedure _LapeImage_Resize2 (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
673698begin
674699 PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Resize(EImageResizeAlgo(Params^[1 ]^), PSingle(Params^[2 ])^);
675700end ;
676701
677702(*
678- TImage.Rotate
703+ TImage.Resize
679704-------------
680705```
681- function TImage.Rotate(Algo: EImageRotateAlgo; Radians: Single; Expand: Boolean): TSimbaImage;
682- ```
683- *)
684- procedure _LapeImage_Rotate (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
685- begin
686- PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Rotate(EImageRotateAlgo(Params^[1 ]^), PSingle(Params^[2 ])^, PBoolean(Params^[3 ])^);
687- end ;
688-
689- (*
690- TImage.Downsample
691- -----------------
692- ```
693- function TImage.Downsample(Scale: Integer): TImage;
706+ function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer; IgnorePoints: TPointArray): TImage;
694707```
708+ Resize, but source pixels listed in `IgnorePoints` are excluded from sampling.
695709*)
696- procedure _LapeImage_DownSample1 (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
710+ procedure _LapeImage_Resize3 (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
697711begin
698- PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Downsample(PInteger (Params^[1 ])^);
712+ PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Resize(EImageResizeAlgo (Params^[1 ]^), PInteger(Params^[ 2 ])^, PInteger(Params^[ 3 ])^, PPointArray(Params^[ 4 ])^);
699713end ;
700714
701715(*
702- TImage.Downsample
703- -----------------
716+ TImage.Rotate
717+ -------------
704718```
705- function TImage.Downsample(Scale: Integer; IgnorePoints: TPointArray ): TImage ;
719+ function TImage.Rotate(Algo: EImageRotateAlgo; Radians: Single; Expand: Boolean ): TSimbaImage ;
706720```
707-
708- Downsample but points in `IgnorePoints` are not sampled from.
709721*)
710- procedure _LapeImage_DownSample2 (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
722+ procedure _LapeImage_Rotate (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
711723begin
712- PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Downsample(PInteger (Params^[1 ])^, PPointArray (Params^[2 ])^);
724+ PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Rotate(EImageRotateAlgo (Params^[1 ]^), PSingle (Params^[2 ])^, PBoolean(Params^[ 3 ])^);
713725end ;
714726
715727(*
@@ -1339,20 +1351,18 @@ procedure _LapeImage_Blend2(const Params: PParamArray; const Result: Pointer); L
13391351TImage.Blur
13401352-----------
13411353```
1342- function TImage.Blur(Algo: EImageBlurAlgo; Radius: Integer): TSimbaImage;
1343- ```
1344-
1345- Algo can be either EImageBlurAlgo.BOX, EImageBlurAlgo.GAUSS.
1354+ function TImage.Blur(Algo: EImageBlurAlgo; Radius: Single): TSimbaImage;
1355+ ``
1356+ Algo can be either `EImageBlurAlgo.BOX` or `EImageBlurAlgo.GAUSS`.
13461357
13471358```{note}
1348- EImageBlurAlgo.GAUSS is not true gaussian blur it's an approximation (in linear time).
1349-
1359+ Gauss is not true gaussian blur it's an approximation (in linear time).
13501360<https://blog.ivank.net/fastest-gaussian-blur.html>
13511361```
13521362*)
13531363procedure _LapeImage_Blur (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
13541364begin
1355- PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Blur(EImageBlurAlgo(Params^[1 ]^), PInteger (Params^[2 ])^);
1365+ PLapeObjectImage(Result)^^ := PLapeObjectImage(Params^[0 ])^^.Blur(EImageBlurAlgo(Params^[1 ]^), PSingle (Params^[2 ])^);
13561366end ;
13571367
13581368(*
@@ -1685,7 +1695,7 @@ procedure ImportSimbaImage(Script: TSimbaScript);
16851695
16861696 addGlobalType(' array of TImage' , ' TImageArray' );
16871697 addGlobalType(' enum(WIDTH, HEIGHT, LINE)' , ' EImageMirrorStyle' );
1688- addGlobalType(' enum(NEAREST_NEIGHBOUR, BILINEAR)' , ' EImageResizeAlgo' );
1698+ addGlobalType(' enum(NEAREST_NEIGHBOUR, BILINEAR, LANCZOS, BOX, HAMMING, BICUBIC )' , ' EImageResizeAlgo' );
16891699 addGlobalType(' enum(NEAREST_NEIGHBOUR, BILINEAR)' , ' EImageRotateAlgo' );
16901700 addGlobalType(' enum(BOX, GAUSS)' , ' EImageBlurAlgo' );
16911701 addGlobalType(' set of enum(LEFT, CENTER, RIGHT, JUSTIFY, TOP, VERTICAL_CENTER, BASE_LINE, BOTTOM)' , ' EImageTextAlign' );
@@ -1748,9 +1758,8 @@ procedure ImportSimbaImage(Script: TSimbaScript);
17481758
17491759 addGlobalFunc(' function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer): TImage; overload;' , @_LapeImage_Resize1);
17501760 addGlobalFunc(' function TImage.Resize(Algo: EImageResizeAlgo; Scale: Single): TImage; overload;' , @_LapeImage_Resize2);
1761+ addGlobalFunc(' function TImage.Resize(Algo: EImageResizeAlgo; NewWidth, NewHeight: Integer; IgnorePoints: TPointArray): TImage; overload;' , @_LapeImage_Resize3);
17511762 addGlobalFunc(' function TImage.Rotate(Algo: EImageRotateAlgo; Radians: Single; Expand: Boolean): TImage;' , @_LapeImage_Rotate);
1752- addGlobalFunc(' function TImage.Downsample(Scale: Integer): TImage; overload' , @_LapeImage_Downsample1);
1753- addGlobalFunc(' function TImage.Downsample(Scale: Integer; IgnorePoints: TPointArray): TImage; overload' , @_LapeImage_Downsample2);
17541763 addGlobalFunc(' function TImage.Mirror(Style: EImageMirrorStyle): TImage' , @_LapeImage_Mirror);
17551764
17561765 addGlobalFunc(' function TImage.TextWidth(Text: String): Integer;' , @_LapeImage_TextWidth);
@@ -1815,7 +1824,7 @@ procedure ImportSimbaImage(Script: TSimbaScript);
18151824 addGlobalFunc(' function TImage.ThresholdAdaptiveSauvola(Invert: Boolean = False; Radius: Integer = 25; C: Single = 0.2): TImage' , @_LapeImage_ThresholdAdaptiveSauvola);
18161825 addGlobalFunc(' function TImage.Blend(Points: TPointArray; Radius: Integer): TImage; overload' , @_LapeImage_Blend1);
18171826 addGlobalFunc(' function TImage.Blend(Points: TPointArray; Radius: Integer; IgnorePoints: TPointArray): TImage; overload' , @_LapeImage_Blend2);
1818- addGlobalFunc(' function TImage.Blur(Algo: EImageBlurAlgo; Radius: Integer ): TImage;' , @_LapeImage_Blur);
1827+ addGlobalFunc(' function TImage.Blur(Algo: EImageBlurAlgo; Radius: Single ): TImage;' , @_LapeImage_Blur);
18191828
18201829 addGlobalFunc(' function TImage.ToGreyMatrix: TByteMatrix' , @_LapeImage_ToGreyMatrix);
18211830 addGlobalFunc(' function TImage.ToMatrix: TIntegerMatrix; overload' , @_LapeImage_ToMatrix1);
0 commit comments