From: Cristy Date: Tue, 15 Aug 2017 01:09:46 +0000 (-0400) Subject: https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=32506 X-Git-Tag: 7.0.6-8~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7cff58d9e8b87859f6dab8959ba6301bb8a5379e;p=imagemagick https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=32506 --- diff --git a/ChangeLog b/ChangeLog index cead76597..dff048198 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2017-08-14 7.0.6-7 Cristy * Fixed numerous memory leaks (reference https://github.com/ImageMagick/ImageMagick/issues). + * Support splin16, spline36, and spline64 resize filters (reference + https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=32506). + * Prevent assertion failure when creating PDF thumbnail (reference + https://github.com/ImageMagick/ImageMagick/issues/674). 2017-08-12 7.0.6-7 Cristy * Release ImageMagick version 7.0.6-7, GIT revision 20799:0db4d8a16:20170812. diff --git a/MagickCore/option.c b/MagickCore/option.c index 5a36b18b1..b36f69468 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -1164,6 +1164,9 @@ static const OptionInfo { "Sinc", SincFilter, UndefinedOptionFlag, MagickFalse }, { "SincFast", SincFastFilter, UndefinedOptionFlag, MagickFalse }, { "Spline", SplineFilter, UndefinedOptionFlag, MagickFalse }, + { "Spline16", Spline16Filter, UndefinedOptionFlag, MagickFalse }, + { "Spline36", Spline36Filter, UndefinedOptionFlag, MagickFalse }, + { "Spline64", Spline64Filter, UndefinedOptionFlag, MagickFalse }, { "Triangle", TriangleFilter, UndefinedOptionFlag, MagickFalse }, { "Welch", WelchFilter, UndefinedOptionFlag, MagickFalse }, { "Welsh", WelchFilter, UndefinedOptionFlag, MagickTrue }, /*misspell*/ diff --git a/MagickCore/resample.h b/MagickCore/resample.h index fe97e91c2..e7461f50d 100644 --- a/MagickCore/resample.h +++ b/MagickCore/resample.h @@ -62,6 +62,9 @@ typedef enum CosineFilter, SplineFilter, LanczosRadiusFilter, + Spline16Filter, + Spline36Filter, + Spline64Filter, SentinelFilter /* a count of all the filters, not a real filter */ } FilterType; diff --git a/MagickCore/resize.c b/MagickCore/resize.c index 70c9ce7d9..b894c9eb9 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -500,6 +500,51 @@ static double SincFast(const double x, } } +static double Spline16(const double x, + const ResizeFilter *magick_unused(resize_filter)) +{ + /* + 2-lobe Spline filter. + */ + if (x < 1.0) + return(((x-9.0/5.0 )*x-1.0/5.0)*x+1.0); + if (x < 2.0) + return(((-1.0/3.0*(x-1.0)+4.0/5.0)*(x-1.0)-7.0/15.0)*(x-1.0)); + return(0.0); +} + +static double Spline36(const double x, + const ResizeFilter *magick_unused(resize_filter)) +{ + /* + 3-lobe Spline filter. + */ + if (x < 1.0) + return(((13.0/11.0*x-453.0/209.0)*x-3.0/209.0)*x+1.0); + if (x < 2.0) + return(((-6.0/11.0*(x-1.0)+270.0/209.0)*(x-1.0)-156.0/209.0)*(x-1.0)); + if (x < 3.0) + return(((1.0/11.0*(x-2.0)-45.0/209.0)*(x-2.0)+26.0/209.0)*(x-2.0)); + return(0.0); +} + +static double Spline64(const double x, + const ResizeFilter *magick_unused(resize_filter)) +{ + /* + 4-lobe Spline filter. + */ + if (x < 1.0) + return(((49.0/41.0*x-6387.0/2911.0)*x-3.0/2911.0)*x+1.0); + if (x < 2.0) + return(((-24.0/41.0*(x-1.0)+4032.0/2911.0)*(x-1.0)-2328.0/2911.0)*(x-1.0)); + if (x < 3.0) + return(((6.0/41.0*(x-2.0)-1008.0/2911.0)*(x-2.0)+582.0/2911.0)*(x-2.0)); + if (x < 4.0) + return(((-1.0/41.0*(x-3.0)+168.0/2911.0)*(x-3.0)-97.0/2911.0)*(x-3.0)); + return(0.0); +} + static double Triangle(const double x, const ResizeFilter *magick_unused(resize_filter)) { @@ -784,6 +829,9 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, { LanczosFilter, CosineFilter }, /* Cosine window (3 lobes) */ { SplineFilter, BoxFilter }, /* Spline Cubic Filter */ { LanczosRadiusFilter, LanczosFilter }, /* Lanczos with integer radius */ + { Spline16Filter, BoxFilter }, /* Spline 16 (2 lobes) */ + { Spline36Filter, BoxFilter }, /* Spline 36 (3 lobes) */ + { Spline16Filter, BoxFilter }, /* Spline 64 (4 lobes) */ }; /* Table mapping the filter/window from the above table to an actual function. @@ -847,6 +895,9 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, { Cosine, 1.0, 1.0, 0.0, 0.0, CosineWeightingFunction }, /* Low level cosine window */ { CubicBC, 2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Cubic B-Spline (B=1,C=0) */ { SincFast, 3.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, Interger Radius */ + { Spline16, 2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Spline 16 2-lobed */ + { Spline36, 3.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Spline 36 3-lobed */ + { Spline64, 4.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Spline 64 4-lobed */ }; /* The known zero crossings of the Jinc() or more accurately the Jinc(x*PI)