% 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, %
#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"
%
% 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)
%
}
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;
%
% 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:
if ( resize_image == (Image *) NULL )
return((Image *) NULL);
- (void) SetImageAlphaChannel(resize_image,DeactivateAlphaChannel,exception);
+ (void) SetImageAlphaChannel(resize_image,DeactivateAlphaChannel,
+ exception);
}
else
{
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);
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);
}
\f
%
% 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)
%
% 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)
{
zero;
ResampleFilter
- **restrict resample_filter;
+ **magick_restrict resample_filter;
ssize_t
j;
i;
register Quantum
- *restrict q;
+ *magick_restrict q;
q=QueueCacheViewAuthenticPixels(distort_view,0,j,distort_image->columns,1,
exception);
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,
i;
register Quantum
- *restrict q;
+ *magick_restrict q;
q=GetCacheViewAuthenticPixels(sparse_view,0,j,sparse_image->columns,
1,exception);
pixel.alpha/=denominator;
break;
}
+ case ManhattanColorInterpolate:
+ {
+ size_t
+ k;
+
+ double
+ minimum = MagickMaximumValue;
+
+ /*
+ Just use the closest control point you can find!
+ */
+ for(k=0; k<number_arguments; k+=2+number_colors) {
+ double distance =
+ fabs((double)i-arguments[ k ])
+ + fabs((double)j-arguments[k+1]);
+ if ( distance < minimum ) {
+ register ssize_t x=(ssize_t) k+2;
+ if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
+ pixel.red=arguments[x++];
+ if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
+ pixel.green=arguments[x++];
+ if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
+ pixel.blue=arguments[x++];
+ if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
+ (image->colorspace == CMYKColorspace))
+ pixel.black=arguments[x++];
+ if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
+ (image->alpha_trait != UndefinedPixelTrait))
+ pixel.alpha=arguments[x++];
+ minimum = distance;
+ }
+ }
+ break;
+ }
case VoronoiColorInterpolate:
default:
{