X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=MagickCore%2Fdistort.c;h=5685cbfd442db7e58e0ba59056e402bf6d1694f9;hb=f19d414d0ac4527544fef324969aa2a5d38b1027;hp=282f0fc03030b6ca5c2f83bfc724030ea72da85f;hpb=d6ef5f386ce4b6199edaa665a2fbca7ab8cbd187;p=imagemagick diff --git a/MagickCore/distort.c b/MagickCore/distort.c index 282f0fc03..5685cbfd4 100644 --- a/MagickCore/distort.c +++ b/MagickCore/distort.c @@ -18,13 +18,13 @@ % June 2007 % % % % % -% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % +% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % -% http://www.imagemagick.org/script/license.php % +% https://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % @@ -51,8 +51,8 @@ #include "MagickCore/exception.h" #include "MagickCore/exception-private.h" #include "MagickCore/gem.h" -#include "MagickCore/hashmap.h" #include "MagickCore/image.h" +#include "MagickCore/linked-list.h" #include "MagickCore/list.h" #include "MagickCore/matrix.h" #include "MagickCore/matrix-private.h" @@ -328,7 +328,7 @@ MagickExport Image *AffineTransformImage(const Image *image, % % The format of the GenerateCoefficients() method is: % -% Image *GenerateCoefficients(const Image *image,DistortImageMethod method, +% Image *GenerateCoefficients(const Image *image,DistortMethod method, % const size_t number_arguments,const double *arguments, % size_t number_values, ExceptionInfo *exception) % @@ -371,8 +371,8 @@ static inline double MagickRound(double x) } static double *GenerateCoefficients(const Image *image, - DistortImageMethod *method,const size_t number_arguments, - const double *arguments,size_t number_values,ExceptionInfo *exception) + DistortMethod *method,const size_t number_arguments,const double *arguments, + size_t number_values,ExceptionInfo *exception) { double *coeff; @@ -1443,7 +1443,7 @@ static double *GenerateCoefficients(const Image *image, % % The format of the DistortResizeImage method is: % -% Image *AdaptiveResizeImage(const Image *image,const size_t columns, +% Image *DistortResizeImage(const Image *image,const size_t columns, % const size_t rows,ExceptionInfo *exception) % % A description of each parameter follows: @@ -1515,7 +1515,8 @@ MagickExport Image *DistortResizeImage(const Image *image, if ( resize_image == (Image *) NULL ) return((Image *) NULL); - (void) SetImageAlphaChannel(resize_image,DeactivateAlphaChannel,exception); + (void) SetImageAlphaChannel(resize_image,DeactivateAlphaChannel, + exception); } else { @@ -1551,10 +1552,8 @@ MagickExport Image *DistortResizeImage(const Image *image, return((Image *) NULL); } /* replace resize images alpha with the separally distorted alpha */ - (void) SetImageAlphaChannel(resize_image,DeactivateAlphaChannel, - exception); - (void) SetImageAlphaChannel(resize_alpha,DeactivateAlphaChannel, - exception); + (void) SetImageAlphaChannel(resize_image,OffAlphaChannel,exception); + (void) SetImageAlphaChannel(resize_alpha,OffAlphaChannel,exception); (void) CompositeImage(resize_image,resize_alpha,CopyAlphaCompositeOp, MagickTrue,0,0,exception); resize_alpha=DestroyImage(resize_alpha); @@ -1572,6 +1571,13 @@ MagickExport Image *DistortResizeImage(const Image *image, tmp_image=resize_image; resize_image=CropImage(tmp_image,&crop_area,exception); tmp_image=DestroyImage(tmp_image); + if (resize_image != (Image *) NULL) + { + resize_image->alpha_trait=image->alpha_trait; + resize_image->compose=image->compose; + resize_image->page.width=0; + resize_image->page.height=0; + } return(resize_image); } @@ -1602,7 +1608,7 @@ MagickExport Image *DistortResizeImage(const Image *image, % % The format of the DistortImage() method is: % -% Image *DistortImage(const Image *image,const DistortImageMethod method, +% Image *DistortImage(const Image *image,const DistortMethod method, % const size_t number_arguments,const double *arguments, % MagickBooleanType bestfit, ExceptionInfo *exception) % @@ -1663,7 +1669,7 @@ MagickExport Image *DistortResizeImage(const Image *image, % instead % */ -MagickExport Image *DistortImage(const Image *image,DistortImageMethod method, +MagickExport Image *DistortImage(const Image *image, DistortMethod method, const size_t number_arguments,const double *arguments, MagickBooleanType bestfit,ExceptionInfo *exception) { @@ -2297,7 +2303,7 @@ MagickExport Image *DistortImage(const Image *image,DistortImageMethod method, zero; ResampleFilter - **restrict resample_filter; + **magick_restrict resample_filter; ssize_t j; @@ -2335,7 +2341,7 @@ MagickExport Image *DistortImage(const Image *image,DistortImageMethod method, i; register Quantum - *restrict q; + *magick_restrict q; q=QueueCacheViewAuthenticPixels(distort_view,0,j,distort_image->columns,1, exception); @@ -2916,10 +2922,10 @@ MagickExport Image *SparseColorImage(const Image *image, Convert input arguments into mapping coefficients, this this case we are mapping (distorting) colors, rather than coordinates. */ - { DistortImageMethod + { DistortMethod distort_method; - distort_method=(DistortImageMethod) method; + distort_method=(DistortMethod) method; if ( distort_method >= SentinelDistortion ) distort_method = ShepardsDistortion; /* Pretend to be Shepards */ coeff = GenerateCoefficients(image, &distort_method, number_arguments, @@ -3046,7 +3052,7 @@ MagickExport Image *SparseColorImage(const Image *image, i; register Quantum - *restrict q; + *magick_restrict q; q=GetCacheViewAuthenticPixels(sparse_view,0,j,sparse_image->columns, 1,exception); @@ -3161,6 +3167,40 @@ MagickExport Image *SparseColorImage(const Image *image, pixel.alpha/=denominator; break; } + case ManhattanColorInterpolate: + { + size_t + k; + + double + minimum = MagickMaximumValue; + + /* + Just use the closest control point you can find! + */ + for(k=0; kcolorspace == CMYKColorspace)) + pixel.black=arguments[x++]; + if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && + (image->alpha_trait != UndefinedPixelTrait)) + pixel.alpha=arguments[x++]; + minimum = distance; + } + } + break; + } case VoronoiColorInterpolate: default: {