% October 1996 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2011 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 %
#include "magick/log.h"
#include "magick/image.h"
#include "magick/image-private.h"
+#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/pixel-private.h"
#include "magick/property.h"
#include "magick/quantum.h"
+#include "magick/quantum-private.h"
#include "magick/random_.h"
#include "magick/random-private.h"
#include "magick/resample.h"
#include "magick/splay-tree.h"
#include "magick/statistic.h"
#include "magick/string_.h"
+#include "magick/string-private.h"
#include "magick/thread-private.h"
#include "magick/transform.h"
#include "magick/utility.h"
#define NotEqualOperator 0xfa
#define LogicalAndOperator 0xfb
#define LogicalOrOperator 0xfc
+#define ExponentialNotation 0xfd
struct _FxInfo
{
% The format of the AcquireFxInfo method is:
%
% FxInfo *AcquireFxInfo(Image *image,const char *expression)
+%
% A description of each parameter follows:
%
% o image: the image.
FxInfo
*fx_info;
- register long
+ register ssize_t
i;
fx_info=(FxInfo *) AcquireMagickMemory(sizeof(*fx_info));
GetImageListLength(fx_info->images),sizeof(*fx_info->resample_filter));
if (fx_info->resample_filter == (ResampleFilter **) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- for (i=0; i < (long) GetImageListLength(fx_info->images); i++)
+ for (i=0; i < (ssize_t) GetImageListLength(fx_info->images); i++)
{
fx_info->resample_filter[i]=AcquireResampleFilter(GetImageFromList(
fx_info->images,i),fx_info->exception);
/*
Convert scientific notation.
*/
- (void) SubstituteString(&fx_info->expression,"0e+","0*10^");
- (void) SubstituteString(&fx_info->expression,"1e+","1*10^");
- (void) SubstituteString(&fx_info->expression,"2e+","2*10^");
- (void) SubstituteString(&fx_info->expression,"3e+","3*10^");
- (void) SubstituteString(&fx_info->expression,"4e+","4*10^");
- (void) SubstituteString(&fx_info->expression,"5e+","5*10^");
- (void) SubstituteString(&fx_info->expression,"6e+","6*10^");
- (void) SubstituteString(&fx_info->expression,"7e+","7*10^");
- (void) SubstituteString(&fx_info->expression,"8e+","8*10^");
- (void) SubstituteString(&fx_info->expression,"9e+","9*10^");
- (void) SubstituteString(&fx_info->expression,"0e-","0*10^-");
- (void) SubstituteString(&fx_info->expression,"1e-","1*10^-");
- (void) SubstituteString(&fx_info->expression,"2e-","2*10^-");
- (void) SubstituteString(&fx_info->expression,"3e-","3*10^-");
- (void) SubstituteString(&fx_info->expression,"4e-","4*10^-");
- (void) SubstituteString(&fx_info->expression,"5e-","5*10^-");
- (void) SubstituteString(&fx_info->expression,"6e-","6*10^-");
- (void) SubstituteString(&fx_info->expression,"7e-","7*10^-");
- (void) SubstituteString(&fx_info->expression,"8e-","8*10^-");
- (void) SubstituteString(&fx_info->expression,"9e-","9*10^-");
+ (void) SubstituteString(&fx_info->expression,"0e+","0**10^");
+ (void) SubstituteString(&fx_info->expression,"1e+","1**10^");
+ (void) SubstituteString(&fx_info->expression,"2e+","2**10^");
+ (void) SubstituteString(&fx_info->expression,"3e+","3**10^");
+ (void) SubstituteString(&fx_info->expression,"4e+","4**10^");
+ (void) SubstituteString(&fx_info->expression,"5e+","5**10^");
+ (void) SubstituteString(&fx_info->expression,"6e+","6**10^");
+ (void) SubstituteString(&fx_info->expression,"7e+","7**10^");
+ (void) SubstituteString(&fx_info->expression,"8e+","8**10^");
+ (void) SubstituteString(&fx_info->expression,"9e+","9**10^");
+ (void) SubstituteString(&fx_info->expression,"0e-","0**10^-");
+ (void) SubstituteString(&fx_info->expression,"1e-","1**10^-");
+ (void) SubstituteString(&fx_info->expression,"2e-","2**10^-");
+ (void) SubstituteString(&fx_info->expression,"3e-","3**10^-");
+ (void) SubstituteString(&fx_info->expression,"4e-","4**10^-");
+ (void) SubstituteString(&fx_info->expression,"5e-","5**10^-");
+ (void) SubstituteString(&fx_info->expression,"6e-","6**10^-");
+ (void) SubstituteString(&fx_info->expression,"7e-","7**10^-");
+ (void) SubstituteString(&fx_info->expression,"8e-","8**10^-");
+ (void) SubstituteString(&fx_info->expression,"9e-","9**10^-");
}
+ /*
+ Force right-to-left associativity for unary negation.
+ */
+ (void) SubstituteString(&fx_info->expression,"-","-1.0*");
/*
Convert complex to simple operators.
*/
(void) SubstituteString(&fx_info->expression,"&&",fx_op);
*fx_op=(char) LogicalOrOperator;
(void) SubstituteString(&fx_info->expression,"||",fx_op);
+ *fx_op=(char) ExponentialNotation;
+ (void) SubstituteString(&fx_info->expression,"**",fx_op);
return(fx_info);
}
\f
{
#define AddNoiseImageTag "AddNoise/Image"
+ CacheView
+ *image_view,
+ *noise_view;
+
const char
*option;
Image
*noise_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickRealType
attenuate;
RandomInfo
- **random_info;
+ **restrict random_info;
- CacheView
- *image_view,
- *noise_view;
+ ssize_t
+ y;
/*
Initialize noise image attributes.
attenuate=1.0;
option=GetImageArtifact(image,"attenuate");
if (option != (char *) NULL)
- attenuate=atof(option);
+ attenuate=StringToDouble(option);
status=MagickTrue;
progress=0;
random_info=AcquireRandomInfoThreadSet();
image_view=AcquireCacheView(image);
noise_view=AcquireCacheView(noise_image);
-#if defined(MAGICKCOREMAGICKCORE_OPENMP_SUPPORT_SUPPORT_DEBUG)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickBooleanType
sync;
register const IndexPacket
- *__restrict indexes;
+ *restrict indexes;
register const PixelPacket
- *__restrict p;
+ *restrict p;
register IndexPacket
- *__restrict noise_indexes;
+ *restrict noise_indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
}
indexes=GetCacheViewVirtualIndexQueue(image_view);
noise_indexes=GetCacheViewAuthenticIndexQueue(noise_view);
- id=GetOpenMPThreadId();
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
if ((channel & RedChannel) != 0)
- q->red=RoundToQuantum(GenerateDifferentialNoise(random_info[id],
+ q->red=ClampToQuantum(GenerateDifferentialNoise(random_info[id],
p->red,noise_type,attenuate));
if ((channel & GreenChannel) != 0)
- q->green=RoundToQuantum(GenerateDifferentialNoise(random_info[id],
+ q->green=ClampToQuantum(GenerateDifferentialNoise(random_info[id],
p->green,noise_type,attenuate));
if ((channel & BlueChannel) != 0)
- q->blue=RoundToQuantum(GenerateDifferentialNoise(random_info[id],
+ q->blue=ClampToQuantum(GenerateDifferentialNoise(random_info[id],
p->blue,noise_type,attenuate));
if ((channel & OpacityChannel) != 0)
- q->opacity=RoundToQuantum(GenerateDifferentialNoise(random_info[id],
+ q->opacity=ClampToQuantum(GenerateDifferentialNoise(random_info[id],
p->opacity,noise_type,attenuate));
if (((channel & IndexChannel) != 0) &&
(image->colorspace == CMYKColorspace))
- noise_indexes[x]=(IndexPacket) RoundToQuantum(GenerateDifferentialNoise(
+ noise_indexes[x]=(IndexPacket) ClampToQuantum(GenerateDifferentialNoise(
random_info[id],indexes[x],noise_type,attenuate));
p++;
q++;
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_AverageImages)
+ #pragma omp critical (MagickCore_AddNoiseImage)
#endif
proceed=SetImageProgress(image,AddNoiseImageTag,progress++,
image->rows);
{
#define BlueShiftImageTag "BlueShift/Image"
+ CacheView
+ *image_view,
+ *shift_view;
+
Image
*shift_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
- CacheView
- *image_view,
- *shift_view;
+ MagickOffsetType
+ progress;
+
+ ssize_t
+ y;
/*
Allocate blue shift image.
progress=0;
image_view=AcquireCacheView(image);
shift_view=AcquireCacheView(shift_image);
-#if defined(MAGICKCOREMAGICKCORE_OPENMP_SUPPORT_SUPPORT_DEBUG)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
MagickBooleanType
sync;
quantum;
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- quantum=p->red;
+ quantum=GetRedPixelComponent(p);
if (p->green < quantum)
- quantum=p->green;
+ quantum=GetGreenPixelComponent(p);
if (p->blue < quantum)
- quantum=p->blue;
+ quantum=GetBluePixelComponent(p);
pixel.red=0.5*(p->red+factor*quantum);
pixel.green=0.5*(p->green+factor*quantum);
pixel.blue=0.5*(p->blue+factor*quantum);
- quantum=p->red;
+ quantum=GetRedPixelComponent(p);
if (p->green > quantum)
- quantum=p->green;
+ quantum=GetGreenPixelComponent(p);
if (p->blue > quantum)
- quantum=p->blue;
+ quantum=GetBluePixelComponent(p);
pixel.red=0.5*(pixel.red+factor*quantum);
pixel.green=0.5*(pixel.green+factor*quantum);
pixel.blue=0.5*(pixel.blue+factor*quantum);
- q->red=RoundToQuantum(pixel.red);
- q->green=RoundToQuantum(pixel.green);
- q->blue=RoundToQuantum(pixel.blue);
+ SetRedPixelComponent(q,ClampRedPixelComponent(&pixel));
+ SetGreenPixelComponent(q,ClampGreenPixelComponent(&pixel));
+ SetBluePixelComponent(q,ClampBluePixelComponent(&pixel));
p++;
q++;
}
MagickBooleanType
proceed;
-#if defined(MAGICKCOREMAGICKCORE_OPENMP_SUPPORT_SUPPORT_DEBUG)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp critical (MagickCore_BlueShiftImage)
#endif
proceed=SetImageProgress(image,BlueShiftImageTag,progress++,
{
#define ColorizeImageTag "Colorize/Image"
+ CacheView
+ *colorize_view,
+ *image_view;
+
GeometryInfo
geometry_info;
Image
*colorize_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickPixelPacket
pixel;
MagickStatusType
flags;
- CacheView
- *colorize_view,
- *image_view;
+ ssize_t
+ y;
/*
Allocate colorized image.
progress=0;
image_view=AcquireCacheView(image);
colorize_view=AcquireCacheView(colorize_image);
-#if defined(MAGICKCOREMAGICKCORE_OPENMP_SUPPORT_SUPPORT_DEBUG)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
MagickBooleanType
sync;
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
q->red=(Quantum) ((p->red*(100.0-pixel.red)+
colorize.red*pixel.red)/100.0);
MagickBooleanType
proceed;
-#if defined(MAGICKCOREMAGICKCORE_OPENMP_SUPPORT_SUPPORT_DEBUG)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp critical (MagickCore_ColorizeImage)
#endif
proceed=SetImageProgress(image,ColorizeImageTag,progress++,image->rows);
% %
% %
% %
-% C o n v o l v e I m a g e %
+% C o l o r M a t r i x I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ConvolveImage() applies a custom convolution kernel to the image.
+% ColorMatrixImage() applies color transformation to an image. This method
+% permits saturation changes, hue rotation, luminance to alpha, and various
+% other effects. Although variable-sized transformation matrices can be used,
+% typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA
+% (or RGBA with offsets). The matrix is similar to those used by Adobe Flash
+% except offsets are in column 6 rather than 5 (in support of CMYKA images)
+% and offsets are normalized (divide Flash offset by 255).
%
-% The format of the ConvolveImage method is:
+% The format of the ColorMatrixImage method is:
%
-% Image *ConvolveImage(const Image *image,const unsigned long order,
-% const double *kernel,ExceptionInfo *exception)
-% Image *ConvolveImageChannel(const Image *image,const ChannelType channel,
-% const unsigned long order,const double *kernel,
-% ExceptionInfo *exception)
+% Image *ColorMatrixImage(const Image *image,
+% const KernelInfo *color_matrix,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
-% o channel: the channel type.
-%
-% o order: the number of columns and rows in the filter kernel.
-%
-% o kernel: An array of double representing the convolution kernel.
+% o color_matrix: the color matrix.
%
% o exception: return any errors or warnings in this structure.
%
*/
-
-MagickExport Image *ConvolveImage(const Image *image,const unsigned long order,
- const double *kernel,ExceptionInfo *exception)
+MagickExport Image *ColorMatrixImage(const Image *image,
+ const KernelInfo *color_matrix,ExceptionInfo *exception)
{
- Image
- *convolve_image;
-
- convolve_image=ConvolveImageChannel(image,DefaultChannels,order,kernel,
- exception);
- return(convolve_image);
-}
+#define ColorMatrixImageTag "ColorMatrix/Image"
-MagickExport Image *ConvolveImageChannel(const Image *image,
- const ChannelType channel,const unsigned long order,const double *kernel,
- ExceptionInfo *exception)
-{
-#define ConvolveImageTag "Convolve/Image"
+ CacheView
+ *color_view,
+ *image_view;
double
- *normal_kernel;
+ ColorMatrix[6][6] =
+ {
+ { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 },
+ { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 },
+ { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 },
+ { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }
+ };
Image
- *convolve_image;
-
- long
- progress,
- y;
+ *color_image;
MagickBooleanType
status;
- MagickPixelPacket
- bias;
-
- MagickRealType
- gamma;
+ MagickOffsetType
+ progress;
- register long
+ register ssize_t
i;
- unsigned long
- width;
-
- CacheView
- *convolve_view,
- *image_view;
+ ssize_t
+ u,
+ v,
+ y;
/*
- Initialize convolve image attributes.
+ Create color matrix.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- width=order;
- if ((width % 2) == 0)
- ThrowImageException(OptionError,"KernelWidthMustBeAnOddNumber");
- convolve_image=CloneImage(image,0,0,MagickTrue,exception);
- if (convolve_image == (Image *) NULL)
+ i=0;
+ for (v=0; v < (ssize_t) color_matrix->height; v++)
+ for (u=0; u < (ssize_t) color_matrix->width; u++)
+ {
+ if ((v < 6) && (u < 6))
+ ColorMatrix[v][u]=color_matrix->values[i];
+ i++;
+ }
+ /*
+ Initialize color image.
+ */
+ color_image=CloneImage(image,0,0,MagickTrue,exception);
+ if (color_image == (Image *) NULL)
return((Image *) NULL);
- if (SetImageStorageClass(convolve_image,DirectClass) == MagickFalse)
+ if (SetImageStorageClass(color_image,DirectClass) == MagickFalse)
{
- InheritException(exception,&convolve_image->exception);
- convolve_image=DestroyImage(convolve_image);
+ InheritException(exception,&color_image->exception);
+ color_image=DestroyImage(color_image);
return((Image *) NULL);
}
if (image->debug != MagickFalse)
format[MaxTextExtent],
*message;
- long
- u,
- v;
-
- register const double
- *k;
-
(void) LogMagickEvent(TransformEvent,GetMagickModule(),
- " ConvolveImage with %ldx%ld kernel:",width,width);
+ " ColorMatrix image with color matrix:");
message=AcquireString("");
- k=kernel;
- for (v=0; v < (long) width; v++)
+ for (v=0; v < 6; v++)
{
*message='\0';
- (void) FormatMagickString(format,MaxTextExtent,"%ld: ",v);
+ (void) FormatMagickString(format,MaxTextExtent,"%.20g: ",(double) v);
(void) ConcatenateString(&message,format);
- for (u=0; u < (long) width; u++)
+ for (u=0; u < 6; u++)
{
- (void) FormatMagickString(format,MaxTextExtent,"%+f ",*k++);
+ (void) FormatMagickString(format,MaxTextExtent,"%+f ",
+ ColorMatrix[v][u]);
(void) ConcatenateString(&message,format);
}
(void) LogMagickEvent(TransformEvent,GetMagickModule(),"%s",message);
message=DestroyString(message);
}
/*
- Normalize kernel.
- */
- normal_kernel=(double *) AcquireQuantumMemory(width*width,
- sizeof(*normal_kernel));
- if (normal_kernel == (double *) NULL)
- {
- convolve_image=DestroyImage(convolve_image);
- ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
- }
- gamma=0.0;
- for (i=0; i < (long) (width*width); i++)
- gamma+=kernel[i];
- gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
- for (i=0; i < (long) (width*width); i++)
- normal_kernel[i]=gamma*kernel[i];
- /*
- Convolve image.
+ ColorMatrix image.
*/
status=MagickTrue;
progress=0;
- GetMagickPixelPacket(image,&bias);
- SetMagickPixelPacketBias(image,&bias);
image_view=AcquireCacheView(image);
- convolve_view=AcquireCacheView(convolve_image);
+ color_view=AcquireCacheView(color_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- MagickBooleanType
- sync;
+ MagickRealType
+ pixel;
register const IndexPacket
- *__restrict indexes;
+ *restrict indexes;
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register IndexPacket
- *__restrict convolve_indexes;
-
- register long
+ register ssize_t
x;
+ register IndexPacket
+ *restrict color_indexes;
+
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
- p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
- 2L),image->columns+width,width,exception);
- q=GetCacheViewAuthenticPixels(convolve_view,0,y,convolve_image->columns,1,
+ p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
+ q=GetCacheViewAuthenticPixels(color_view,0,y,color_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
continue;
}
indexes=GetCacheViewVirtualIndexQueue(image_view);
- convolve_indexes=GetCacheViewAuthenticIndexQueue(convolve_view);
- for (x=0; x < (long) image->columns; x++)
+ color_indexes=GetCacheViewAuthenticIndexQueue(color_view);
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- long
+ register ssize_t
v;
- MagickPixelPacket
- pixel;
-
- register const double
- *__restrict k;
+ size_t
+ height;
- register const PixelPacket
- *__restrict kernel_pixels;
-
- register long
- u;
-
- pixel=bias;
- k=normal_kernel;
- kernel_pixels=p;
- if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
+ height=color_matrix->height > 6 ? 6UL : color_matrix->height;
+ for (v=0; v < (ssize_t) height; v++)
+ {
+ pixel=ColorMatrix[v][0]*p->red+ColorMatrix[v][1]*p->green+
+ ColorMatrix[v][2]*p->blue;
+ if (image->matte != MagickFalse)
+ pixel+=ColorMatrix[v][3]*(QuantumRange-p->opacity);
+ if (image->colorspace == CMYKColorspace)
+ pixel+=ColorMatrix[v][4]*indexes[x];
+ pixel+=QuantumRange*ColorMatrix[v][5];
+ switch (v)
{
- for (v=0; v < (long) width; v++)
+ case 0: q->red=ClampToQuantum(pixel); break;
+ case 1: q->green=ClampToQuantum(pixel); break;
+ case 2: q->blue=ClampToQuantum(pixel); break;
+ case 3:
{
- for (u=0; u < (long) width; u++)
- {
- pixel.red+=(*k)*kernel_pixels[u].red;
- pixel.green+=(*k)*kernel_pixels[u].green;
- pixel.blue+=(*k)*kernel_pixels[u].blue;
- k++;
- }
- kernel_pixels+=image->columns+width;
+ if (image->matte != MagickFalse)
+ q->opacity=ClampToQuantum(QuantumRange-pixel);
+ break;
}
- if ((channel & RedChannel) != 0)
- q->red=RoundToQuantum(pixel.red);
- if ((channel & GreenChannel) != 0)
- q->green=RoundToQuantum(pixel.green);
- if ((channel & BlueChannel) != 0)
- q->blue=RoundToQuantum(pixel.blue);
- if ((channel & OpacityChannel) != 0)
- {
- k=normal_kernel;
- kernel_pixels=p;
- for (v=0; v < (long) width; v++)
- {
- for (u=0; u < (long) width; u++)
- {
- pixel.opacity+=(*k)*kernel_pixels[u].opacity;
- k++;
- }
- kernel_pixels+=image->columns+width;
- }
- q->opacity=RoundToQuantum(pixel.opacity);
- }
- if (((channel & IndexChannel) != 0) &&
- (image->colorspace == CMYKColorspace))
- {
- register const IndexPacket
- *__restrict kernel_indexes;
-
- k=normal_kernel;
- kernel_indexes=indexes;
- for (v=0; v < (long) width; v++)
- {
- for (u=0; u < (long) width; u++)
- {
- pixel.index+=(*k)*kernel_indexes[u];
- k++;
- }
- kernel_indexes+=image->columns+width;
- }
- convolve_indexes[x]=RoundToQuantum(pixel.index);
- }
- }
- else
- {
- MagickRealType
- alpha,
- gamma;
-
- gamma=0.0;
- for (v=0; v < (long) width; v++)
+ case 4:
{
- for (u=0; u < (long) width; u++)
- {
- alpha=(MagickRealType) (QuantumScale*(QuantumRange-
- kernel_pixels[u].opacity));
- pixel.red+=(*k)*alpha*kernel_pixels[u].red;
- pixel.green+=(*k)*alpha*kernel_pixels[u].green;
- pixel.blue+=(*k)*alpha*kernel_pixels[u].blue;
- pixel.opacity+=(*k)*kernel_pixels[u].opacity;
- gamma+=(*k)*alpha;
- k++;
- }
- kernel_pixels+=image->columns+width;
- }
- gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
- if ((channel & RedChannel) != 0)
- q->red=RoundToQuantum(gamma*pixel.red);
- if ((channel & GreenChannel) != 0)
- q->green=RoundToQuantum(gamma*pixel.green);
- if ((channel & BlueChannel) != 0)
- q->blue=RoundToQuantum(gamma*pixel.blue);
- if ((channel & OpacityChannel) != 0)
- {
- k=normal_kernel;
- kernel_pixels=p;
- for (v=0; v < (long) width; v++)
- {
- for (u=0; u < (long) width; u++)
- {
- pixel.opacity+=(*k)*kernel_pixels[u].opacity;
- k++;
- }
- kernel_pixels+=image->columns+width;
- }
- q->opacity=RoundToQuantum(pixel.opacity);
- }
- if (((channel & IndexChannel) != 0) &&
- (image->colorspace == CMYKColorspace))
- {
- register const IndexPacket
- *__restrict kernel_indexes;
-
- k=normal_kernel;
- kernel_pixels=p;
- kernel_indexes=indexes;
- for (v=0; v < (long) width; v++)
- {
- for (u=0; u < (long) width; u++)
- {
- alpha=(MagickRealType) (QuantumScale*(QuantumRange-
- kernel_pixels[u].opacity));
- pixel.index+=(*k)*alpha*kernel_indexes[u];
- k++;
- }
- kernel_pixels+=image->columns+width;
- kernel_indexes+=image->columns+width;
- }
- convolve_indexes[x]=RoundToQuantum(gamma*pixel.index);
- }
- }
- p++;
- q++;
- }
- sync=SyncCacheViewAuthenticPixels(convolve_view,exception);
- if (sync == MagickFalse)
- status=MagickFalse;
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_ConvolveImageChannel)
-#endif
- proceed=SetImageProgress(image,ConvolveImageTag,progress++,image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- convolve_image->type=image->type;
- convolve_view=DestroyCacheView(convolve_view);
- image_view=DestroyCacheView(image_view);
- normal_kernel=(double *) RelinquishMagickMemory(normal_kernel);
- if (status == MagickFalse)
- convolve_image=DestroyImage(convolve_image);
- return(convolve_image);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ D e s t r o y F x I n f o %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DestroyFxInfo() deallocates memory associated with an FxInfo structure.
-%
-% The format of the DestroyFxInfo method is:
-%
-% ImageInfo *DestroyFxInfo(ImageInfo *fx_info)
-%
-% A description of each parameter follows:
-%
-% o fx_info: the fx info.
-%
-*/
-MagickExport FxInfo *DestroyFxInfo(FxInfo *fx_info)
-{
- register long
- i;
-
- fx_info->exception=DestroyExceptionInfo(fx_info->exception);
- fx_info->expression=DestroyString(fx_info->expression);
- fx_info->symbols=DestroySplayTree(fx_info->symbols);
- fx_info->colors=DestroySplayTree(fx_info->colors);
- for (i=0; i < (long) GetImageListLength(fx_info->images); i++)
- fx_info->resample_filter[i]=DestroyResampleFilter(
- fx_info->resample_filter[i]);
- fx_info->resample_filter=(ResampleFilter **) RelinquishMagickMemory(
- fx_info->resample_filter);
- fx_info->random_info=DestroyRandomInfo(fx_info->random_info);
- fx_info=(FxInfo *) RelinquishMagickMemory(fx_info);
- return(fx_info);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% E v a l u a t e I m a g e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% EvaluateImage() applies a value to the image with an arithmetic, relational,
-% or logical operator to an image. Use these operations to lighten or darken
-% an image, to increase or decrease contrast in an image, or to produce the
-% "negative" of an image.
-%
-% The format of the EvaluateImageChannel method is:
-%
-% MagickBooleanType EvaluateImage(Image *image,
-% const MagickEvaluateOperator op,const double value,
-% ExceptionInfo *exception)
-% MagickBooleanType EvaluateImageChannel(Image *image,
-% const ChannelType channel,const MagickEvaluateOperator op,
-% const double value,ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-% o channel: the channel.
-%
-% o op: A channel op.
-%
-% o value: A value value.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-
-static inline double MagickMax(const double x,const double y)
-{
- if (x > y)
- return(x);
- return(y);
-}
-
-static inline double MagickMin(const double x,const double y)
-{
- if (x < y)
- return(x);
- return(y);
-}
-
-static Quantum ApplyEvaluateOperator(RandomInfo *random_info,Quantum pixel,
- const MagickEvaluateOperator op,const MagickRealType value)
-{
- MagickRealType
- result;
-
- result=0.0;
- switch (op)
- {
- case UndefinedEvaluateOperator:
- break;
- case AddEvaluateOperator:
- {
- result=(MagickRealType) (pixel+value);
- break;
- }
- case AddModulusEvaluateOperator:
- {
- /* This will return a 'floored modulus' of the addition which will
- * always return a positive result, regardless of if the result is
- * positive or negative, and thus in the 0 to QuantumRange range.
- *
- * WARNING: this is NOT the same as a % or fmod() which returns a
- * 'truncated modulus' result, where floor() is replaced by trunc()
- * and could return a negative result, which will be clipped.
- */
- result = pixel+value;
- result -= (QuantumRange+1)*floor(result/(QuantumRange+1));
- break;
- }
- case AndEvaluateOperator:
- {
- result=(MagickRealType) ((unsigned long) pixel & (unsigned long)
- (value+0.5));
- break;
- }
- case CosineEvaluateOperator:
- {
- result=(MagickRealType) (QuantumRange*(0.5*cos((double) (2.0*MagickPI*
- QuantumScale*pixel*value))+0.5));
- break;
- }
- case DivideEvaluateOperator:
- {
- result=pixel/(value == 0.0 ? 1.0 : value);
- break;
- }
- case GaussianNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- GaussianNoise,value);
- break;
- }
- case ImpulseNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- ImpulseNoise,value);
- break;
- }
- case LaplacianNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- LaplacianNoise,value);
- break;
- }
- case LeftShiftEvaluateOperator:
- {
- result=(MagickRealType) ((unsigned long) pixel << (unsigned long)
- (value+0.5));
- break;
- }
- case LogEvaluateOperator:
- {
- result=(MagickRealType) (QuantumRange*log((double) (QuantumScale*value*
- pixel+1.0))/log((double) (value+1.0)));
- break;
- }
- case MaxEvaluateOperator:
- {
- result=(MagickRealType) MagickMax((double) pixel,value);
- break;
- }
- case MinEvaluateOperator:
- {
- result=(MagickRealType) MagickMin((double) pixel,value);
- break;
- }
- case MultiplicativeNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- MultiplicativeGaussianNoise,value);
- break;
- }
- case MultiplyEvaluateOperator:
- {
- result=(MagickRealType) (value*pixel);
- break;
- }
- case OrEvaluateOperator:
- {
- result=(MagickRealType) ((unsigned long) pixel | (unsigned long)
- (value+0.5));
- break;
- }
- case PoissonNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- PoissonNoise,value);
- break;
- }
- case PowEvaluateOperator:
- {
- result=(MagickRealType) (QuantumRange*pow((double) (QuantumScale*pixel),
- (double) value));
- break;
- }
- case RightShiftEvaluateOperator:
- {
- result=(MagickRealType) ((unsigned long) pixel >> (unsigned long)
- (value+0.5));
- break;
- }
- case SetEvaluateOperator:
- {
- result=value;
- break;
- }
- case SineEvaluateOperator:
- {
- result=(MagickRealType) (QuantumRange*(0.5*sin((double) (2.0*MagickPI*
- QuantumScale*pixel*value))+0.5));
- break;
- }
- case SubtractEvaluateOperator:
- {
- result=(MagickRealType) (pixel-value);
- break;
- }
- case ThresholdEvaluateOperator:
- {
- result=(MagickRealType) (((MagickRealType) pixel <= value) ? 0 :
- QuantumRange);
- break;
- }
- case ThresholdBlackEvaluateOperator:
- {
- result=(MagickRealType) (((MagickRealType) pixel <= value) ? 0 : pixel);
- break;
- }
- case ThresholdWhiteEvaluateOperator:
- {
- result=(MagickRealType) (((MagickRealType) pixel > value) ? QuantumRange :
- pixel);
- break;
- }
- case UniformNoiseEvaluateOperator:
- {
- result=(MagickRealType) GenerateDifferentialNoise(random_info,pixel,
- UniformNoise,value);
- break;
- }
- case XorEvaluateOperator:
- {
- result=(MagickRealType) ((unsigned long) pixel ^ (unsigned long)
- (value+0.5));
- break;
- }
- }
- return(RoundToQuantum(result));
-}
-
-MagickExport MagickBooleanType EvaluateImage(Image *image,
- const MagickEvaluateOperator op,const double value,ExceptionInfo *exception)
-{
- MagickBooleanType
- status;
-
- status=EvaluateImageChannel(image,AllChannels,op,value,exception);
- return(status);
-}
-
-MagickExport MagickBooleanType EvaluateImageChannel(Image *image,
- const ChannelType channel,const MagickEvaluateOperator op,const double value,
- ExceptionInfo *exception)
-{
-#define EvaluateImageTag "Evaluate/Image "
-
- long
- progress,
- y;
-
- MagickBooleanType
- status;
-
- RandomInfo
- **random_info;
-
- CacheView
- *image_view;
-
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
- {
- InheritException(exception,&image->exception);
- return(MagickFalse);
- }
- status=MagickTrue;
- progress=0;
- random_info=AcquireRandomInfoThreadSet();
- image_view=AcquireCacheView(image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
-#endif
- for (y=0; y < (long) image->rows; y++)
- {
- register IndexPacket
- *__restrict indexes;
-
- register long
- id,
- x;
-
- register PixelPacket
- *__restrict q;
-
- if (status == MagickFalse)
- continue;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
- {
- status=MagickFalse;
- continue;
- }
- indexes=GetCacheViewAuthenticIndexQueue(image_view);
- id=GetOpenMPThreadId();
- for (x=0; x < (long) image->columns; x++)
- {
- if ((channel & RedChannel) != 0)
- q->red=ApplyEvaluateOperator(random_info[id],q->red,op,value);
- if ((channel & GreenChannel) != 0)
- q->green=ApplyEvaluateOperator(random_info[id],q->green,op,value);
- if ((channel & BlueChannel) != 0)
- q->blue=ApplyEvaluateOperator(random_info[id],q->blue,op,value);
- if ((channel & OpacityChannel) != 0)
- {
- if (image->matte == MagickFalse)
- q->opacity=ApplyEvaluateOperator(random_info[id],q->opacity,op,
- value);
- else
- q->opacity=(Quantum) QuantumRange-ApplyEvaluateOperator(
- random_info[id],(Quantum) (QuantumRange-q->opacity),op,value);
- }
- if (((channel & IndexChannel) != 0) && (indexes != (IndexPacket *) NULL))
- indexes[x]=(IndexPacket) ApplyEvaluateOperator(random_info[id],
- indexes[x],op,value);
- q++;
- }
- if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
- status=MagickFalse;
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_EvaluateImageChannel)
-#endif
- proceed=SetImageProgress(image,EvaluateImageTag,progress++,image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- image_view=DestroyCacheView(image_view);
- random_info=DestroyRandomInfoThreadSet(random_info);
- return(status);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% F u n c t i o n I m a g e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FunctionImage() applies a value to the image with an arithmetic, relational,
-% or logical operator to an image. Use these operations to lighten or darken
-% an image, to increase or decrease contrast in an image, or to produce the
-% "negative" of an image.
-%
-% The format of the FunctionImageChannel method is:
-%
-% MagickBooleanType FunctionImage(Image *image,
-% const MagickFunction function,const long number_parameters,
-% const double *parameters,ExceptionInfo *exception)
-% MagickBooleanType FunctionImageChannel(Image *image,
-% const ChannelType channel,const MagickFunction function,
-% const long number_parameters,const double *argument,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-% o channel: the channel.
-%
-% o function: A channel function.
-%
-% o parameters: one or more parameters.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-
-static Quantum ApplyFunction(Quantum pixel,const MagickFunction function,
- const unsigned long number_parameters,const double *parameters,
- ExceptionInfo *exception)
-{
- MagickRealType
- result;
-
- register long
- i;
-
- (void) exception;
- result=0.0;
- switch (function)
- {
- case PolynomialFunction:
- {
- /*
- * Polynomial
- * Parameters: polynomial constants, highest to lowest order
- * For example: c0*x^3 + c1*x^2 + c2*x + c3
- */
- result=0.0;
- for (i=0; i < (long) number_parameters; i++)
- result = result*QuantumScale*pixel + parameters[i];
- result *= QuantumRange;
- break;
- }
- case SinusoidFunction:
- {
- /* Sinusoid Function
- * Parameters: Freq, Phase, Ampl, bias
- */
- double freq,phase,ampl,bias;
- freq = ( number_parameters >= 1 ) ? parameters[0] : 1.0;
- phase = ( number_parameters >= 2 ) ? parameters[1] : 0.0;
- ampl = ( number_parameters >= 3 ) ? parameters[2] : 0.5;
- bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5;
- result=(MagickRealType) (QuantumRange*(ampl*sin((double) (2.0*MagickPI*
- (freq*QuantumScale*pixel + phase/360.0) )) + bias ) );
- break;
- }
- case ArcsinFunction:
- {
- /* Arcsin Function (peged at range limits for invalid results)
- * Parameters: Width, Center, Range, Bias
- */
- double width,range,center,bias;
- width = ( number_parameters >= 1 ) ? parameters[0] : 1.0;
- center = ( number_parameters >= 2 ) ? parameters[1] : 0.5;
- range = ( number_parameters >= 3 ) ? parameters[2] : 1.0;
- bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5;
- result = 2.0/width*(QuantumScale*pixel - center);
- if ( result <= -1.0 )
- result = bias - range/2.0;
- else if ( result >= 1.0 )
- result = bias + range/2.0;
- else
- result=range/MagickPI*asin((double)result) + bias;
- result *= QuantumRange;
- break;
- }
- case ArctanFunction:
- {
- /* Arctan Function
- * Parameters: Slope, Center, Range, Bias
- */
- double slope,range,center,bias;
- slope = ( number_parameters >= 1 ) ? parameters[0] : 1.0;
- center = ( number_parameters >= 2 ) ? parameters[1] : 0.5;
- range = ( number_parameters >= 3 ) ? parameters[2] : 1.0;
- bias = ( number_parameters >= 4 ) ? parameters[3] : 0.5;
- result = MagickPI*slope*(QuantumScale*pixel - center);
- result=(MagickRealType) (QuantumRange*(range/MagickPI*atan((double)
- result) + bias ) );
- break;
- }
- case UndefinedFunction:
- break;
- }
- return(RoundToQuantum(result));
-}
-
-MagickExport MagickBooleanType FunctionImage(Image *image,
- const MagickFunction function,const unsigned long number_parameters,
- const double *parameters,ExceptionInfo *exception)
-{
- MagickBooleanType
- status;
-
- status=FunctionImageChannel(image,AllChannels,function,number_parameters,
- parameters,exception);
- return(status);
-}
-
-MagickExport MagickBooleanType FunctionImageChannel(Image *image,
- const ChannelType channel,const MagickFunction function,
- const unsigned long number_parameters,const double *parameters,
- ExceptionInfo *exception)
-{
-#define FunctionImageTag "Function/Image "
-
- long
- progress,
- y;
-
- MagickBooleanType
- status;
-
- CacheView
- *image_view;
-
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
- {
- InheritException(exception,&image->exception);
- return(MagickFalse);
- }
- status=MagickTrue;
- progress=0;
- image_view=AcquireCacheView(image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
-#endif
- for (y=0; y < (long) image->rows; y++)
- {
- register IndexPacket
- *__restrict indexes;
-
- register long
- x;
-
- register PixelPacket
- *__restrict q;
-
- if (status == MagickFalse)
- continue;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
- {
- status=MagickFalse;
- continue;
- }
- indexes=GetCacheViewAuthenticIndexQueue(image_view);
- for (x=0; x < (long) image->columns; x++)
- {
- if ((channel & RedChannel) != 0)
- q->red=ApplyFunction(q->red,function,number_parameters,parameters,
- exception);
- if ((channel & GreenChannel) != 0)
- q->green=ApplyFunction(q->green,function,number_parameters,parameters,
- exception);
- if ((channel & BlueChannel) != 0)
- q->blue=ApplyFunction(q->blue,function,number_parameters,parameters,
- exception);
- if ((channel & OpacityChannel) != 0)
- {
- if (image->matte == MagickFalse)
- q->opacity=ApplyFunction(q->opacity,function,number_parameters,
- parameters,exception);
- else
- q->opacity=(Quantum) QuantumRange-ApplyFunction((Quantum) (
- QuantumRange-q->opacity),function,number_parameters,parameters,
- exception);
+ if (image->colorspace == CMYKColorspace)
+ color_indexes[x]=ClampToQuantum(pixel);
+ break;
+ }
}
- if (((channel & IndexChannel) != 0) && (indexes != (IndexPacket *) NULL))
- indexes[x]=(IndexPacket) ApplyFunction(indexes[x],function,
- number_parameters,parameters,exception);
+ }
+ p++;
q++;
}
- if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+ if (SyncCacheViewAuthenticPixels(color_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_FunctionImageChannel)
+ #pragma omp critical (MagickCore_ColorMatrixImage)
#endif
- proceed=SetImageProgress(image,FunctionImageTag,progress++,image->rows);
+ proceed=SetImageProgress(image,ColorMatrixImageTag,progress++,
+ image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
+ color_view=DestroyCacheView(color_view);
image_view=DestroyCacheView(image_view);
- return(status);
+ if (status == MagickFalse)
+ color_image=DestroyImage(color_image);
+ return(color_image);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
++ D e s t r o y F x I n f o %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DestroyFxInfo() deallocates memory associated with an FxInfo structure.
+%
+% The format of the DestroyFxInfo method is:
+%
+% ImageInfo *DestroyFxInfo(ImageInfo *fx_info)
+%
+% A description of each parameter follows:
+%
+% o fx_info: the fx info.
+%
+*/
+MagickExport FxInfo *DestroyFxInfo(FxInfo *fx_info)
+{
+ register ssize_t
+ i;
+
+ fx_info->exception=DestroyExceptionInfo(fx_info->exception);
+ fx_info->expression=DestroyString(fx_info->expression);
+ fx_info->symbols=DestroySplayTree(fx_info->symbols);
+ fx_info->colors=DestroySplayTree(fx_info->colors);
+ for (i=0; i < (ssize_t) GetImageListLength(fx_info->images); i++)
+ fx_info->resample_filter[i]=DestroyResampleFilter(
+ fx_info->resample_filter[i]);
+ fx_info->resample_filter=(ResampleFilter **) RelinquishMagickMemory(
+ fx_info->resample_filter);
+ fx_info->random_info=DestroyRandomInfo(fx_info->random_info);
+ fx_info=(FxInfo *) RelinquishMagickMemory(fx_info);
+ return(fx_info);
}
\f
/*
% The format of the FxEvaluateExpression method is:
%
% MagickRealType FxEvaluateChannelExpression(FxInfo *fx_info,
-% const ChannelType channel,const long x,const long y,
+% const ChannelType channel,const ssize_t x,const ssize_t y,
% MagickRealType *alpha,Exceptioninfo *exception)
% MagickRealType FxEvaluateExpression(FxInfo *fx_info,
% MagickRealType *alpha,Exceptioninfo *exception)
%
*/
+static inline double MagickMax(const double x,const double y)
+{
+ if (x > y)
+ return(x);
+ return(y);
+}
+
+static inline double MagickMin(const double x,const double y)
+{
+ if (x < y)
+ return(x);
+ return(y);
+}
+
static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
ChannelType channel,const char *symbol,ExceptionInfo *exception)
{
case 'k': channel=BlackChannel; break;
default: break;
}
- (void) FormatMagickString(key,MaxTextExtent,"%p.%ld.%s",image,(long) channel,
- symbol);
+ (void) FormatMagickString(key,MaxTextExtent,"%p.%.20g.%s",(void *) image,
+ (double) channel,symbol);
value=(const char *) GetValueFromSplayTree(fx_info->symbols,key);
if (value != (const char *) NULL)
- return(QuantumScale*atof(value));
+ return(QuantumScale*StringToDouble(value));
(void) DeleteNodeFromSplayTree(fx_info->symbols,key);
if (LocaleNCompare(symbol,"depth",5) == 0)
{
- unsigned long
+ size_t
depth;
depth=GetImageChannelDepth(image,channel,exception);
- (void) FormatMagickString(statistic,MaxTextExtent,"%lu",depth);
+ (void) FormatMagickString(statistic,MaxTextExtent,"%.20g",(double)
+ depth);
}
if (LocaleNCompare(symbol,"kurtosis",8) == 0)
{
}
(void) AddValueToSplayTree(fx_info->symbols,ConstantString(key),
ConstantString(statistic));
- return(QuantumScale*atof(statistic));
+ return(QuantumScale*StringToDouble(statistic));
}
static MagickRealType
- FxEvaluateSubexpression(FxInfo *,const ChannelType,const long,const long,
- const char *,MagickRealType *,ExceptionInfo *);
+ FxEvaluateSubexpression(FxInfo *,const ChannelType,const ssize_t,
+ const ssize_t,const char *,MagickRealType *,ExceptionInfo *);
static inline MagickRealType FxMax(FxInfo *fx_info,const ChannelType channel,
- const long x,const long y,const char *expression,ExceptionInfo *exception)
+ const ssize_t x,const ssize_t y,const char *expression,
+ ExceptionInfo *exception)
{
MagickRealType
alpha,
}
static inline MagickRealType FxMin(FxInfo *fx_info,ChannelType channel,
- const long x,const long y,const char *expression,ExceptionInfo *exception)
+ const ssize_t x,const ssize_t y,const char *expression,
+ ExceptionInfo *exception)
{
MagickRealType
alpha,
const char
*subexpression;
- register long
+ register ssize_t
level;
level=0;
}
static MagickRealType FxGetSymbol(FxInfo *fx_info,const ChannelType channel,
- const long x,const long y,const char *expression,ExceptionInfo *exception)
+ const ssize_t x,const ssize_t y,const char *expression,
+ ExceptionInfo *exception)
{
char
*q,
PointInfo
point;
- register long
+ register ssize_t
i;
size_t
length;
- unsigned long
+ size_t
level;
p=expression;
*q='\0';
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,
&beta,exception);
- i=(long) (alpha+0.5);
+ i=(ssize_t) (alpha+0.5);
p++;
}
if (*p == '.')
}
length=GetImageListLength(fx_info->images);
while (i < 0)
- i+=(long) length;
+ i+=(ssize_t) length;
i%=length;
image=GetImageFromList(fx_info->images,i);
if (image == (Image *) NULL)
fx_info->matte=MagickFalse;
return(1.0);
}
- return((MagickRealType) (QuantumScale*(QuantumRange-pixel.opacity)));
+ return((MagickRealType) (QuantumScale*GetAlphaPixelComponent(&pixel)));
}
case IndexChannel:
{
case 'a':
{
if (LocaleCompare(symbol,"a") == 0)
- return((MagickRealType) (QuantumScale*(QuantumRange-pixel.opacity)));
+ return((MagickRealType) (QuantumScale*GetAlphaPixelComponent(&pixel)));
break;
}
case 'B':
lightness,
saturation;
- ConvertRGBToHSL(RoundToQuantum(pixel.red),RoundToQuantum(pixel.green),
- RoundToQuantum(pixel.blue),&hue,&saturation,&lightness);
+ ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
+ ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
return(hue);
}
break;
lightness,
saturation;
- ConvertRGBToHSL(RoundToQuantum(pixel.red),RoundToQuantum(pixel.green),
- RoundToQuantum(pixel.blue),&hue,&saturation,&lightness);
+ ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
+ ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
return(lightness);
}
if (LocaleCompare(symbol,"luminance") == 0)
lightness,
saturation;
- ConvertRGBToHSL(RoundToQuantum(pixel.red),RoundToQuantum(pixel.green),
- RoundToQuantum(pixel.blue),&hue,&saturation,&lightness);
+ ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
+ ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
return(saturation);
}
if (LocaleNCompare(symbol,"skewness",8) == 0)
}
value=(const char *) GetValueFromSplayTree(fx_info->symbols,symbol);
if (value != (const char *) NULL)
- return((MagickRealType) atof(value));
+ return((MagickRealType) StringToDouble(value));
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"UnableToParseExpression","`%s'",symbol);
return(0.0);
NullPrecedence,
BitwiseComplementPrecedence,
ExponentPrecedence,
+ ExponentialNotationPrecedence,
MultiplyPrecedence,
AdditionPrecedence,
ShiftPrecedence,
register int
c;
- unsigned long
+ size_t
level;
c=0;
expression++;
continue;
}
- if (LocaleNCompare(expression,"atan2",5) == 0)
+ switch (*expression)
+ {
+ case 'A':
+ case 'a':
{
- expression+=5;
- continue;
+ if (LocaleNCompare(expression,"atan2",5) == 0)
+ {
+ expression+=5;
+ break;
+ }
+ break;
+ }
+ case 'J':
+ case 'j':
+ {
+ if ((LocaleNCompare(expression,"j0",2) == 0) ||
+ (LocaleNCompare(expression,"j1",2) == 0))
+ {
+ expression+=2;
+ break;
+ }
+ break;
+ }
+ case '#':
+ {
+ while (isxdigit((int) ((unsigned char) *(expression+1))) != 0)
+ expression++;
+ break;
}
+ default:
+ break;
+ }
if ((c == (int) '{') || (c == (int) '['))
level++;
else
break;
}
case '^':
+ case '@':
{
precedence=ExponentPrecedence;
break;
precedence=LogicalOrPrecedence;
break;
}
+ case ExponentialNotation:
+ {
+ precedence=ExponentialNotationPrecedence;
+ break;
+ }
case ':':
case '?':
{
}
static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
- const ChannelType channel,const long x,const long y,const char *expression,
- MagickRealType *beta,ExceptionInfo *exception)
+ const ChannelType channel,const ssize_t x,const ssize_t y,
+ const char *expression,MagickRealType *beta,ExceptionInfo *exception)
{
char
*q,
"MissingExpression","`%s'",expression);
return(0.0);
}
+ *subexpression='\0';
p=FxOperatorPrecedence(expression,exception);
if (p != (const char *) NULL)
{
case '~':
{
*beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- *beta=(MagickRealType) (~(unsigned long) *beta);
+ *beta=(MagickRealType) (~(size_t) *beta);
return(*beta);
}
case '!':
return(*beta);
}
case '*':
+ case ExponentialNotation:
{
*beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
return(alpha*(*beta));
case LeftShiftOperator:
{
gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- *beta=(MagickRealType) ((unsigned long) (alpha+0.5) << (unsigned long)
+ *beta=(MagickRealType) ((size_t) (alpha+0.5) << (size_t)
(gamma+0.5));
return(*beta);
}
case RightShiftOperator:
{
gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- *beta=(MagickRealType) ((unsigned long) (alpha+0.5) >> (unsigned long)
+ *beta=(MagickRealType) ((size_t) (alpha+0.5) >> (size_t)
(gamma+0.5));
return(*beta);
}
case '&':
{
gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- *beta=(MagickRealType) ((unsigned long) (alpha+0.5) & (unsigned long)
+ *beta=(MagickRealType) ((size_t) (alpha+0.5) & (size_t)
(gamma+0.5));
return(*beta);
}
case '|':
{
gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- *beta=(MagickRealType) ((unsigned long) (alpha+0.5) | (unsigned long)
+ *beta=(MagickRealType) ((size_t) (alpha+0.5) | (size_t)
(gamma+0.5));
return(*beta);
}
}
ClearMagickException(exception);
*beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
- (void) FormatMagickString(numeric,MaxTextExtent,"%g",(double) *beta);
+ (void) FormatMagickString(numeric,MaxTextExtent,"%g",(double)
+ *beta);
(void) DeleteNodeFromSplayTree(fx_info->symbols,subexpression);
(void) AddValueToSplayTree(fx_info->symbols,ConstantString(
subexpression),ConstantString(numeric));
{
gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
exception);
- return((MagickRealType) (~(unsigned long) (gamma+0.5)));
+ return((MagickRealType) (~(size_t) (gamma+0.5)));
}
case 'A':
case 'a':
exception);
return((MagickRealType) acos((double) alpha));
}
+#if defined(MAGICKCORE_HAVE_J1)
+ if (LocaleNCompare(expression,"airy",4) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
+ exception);
+ if (alpha == 0.0)
+ return(1.0);
+ gamma=2.0*j1((double) (MagickPI*alpha))/(MagickPI*alpha);
+ return(gamma*gamma);
+ }
+#endif
if (LocaleNCompare(expression,"asin",4) == 0)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
exception);
- return(((long) alpha) & 0x01 ? -1.0 : 1.0);
+ return(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
}
if (LocaleNCompare(expression,"atan2",5) == 0)
{
if (strlen(subexpression) > 1)
subexpression[strlen(subexpression)-1]='\0';
if (fx_info->file != (FILE *) NULL)
- (void) fprintf(fx_info->file,"%s[%ld,%ld].%s: %s=%g\n",
- fx_info->images->filename,x,y,type,subexpression,(double) alpha);
+ (void) fprintf(fx_info->file,"%s[%.20g,%.20g].%s: %s=%.*g\n",
+ fx_info->images->filename,(double) x,(double) y,type,
+ subexpression,GetMagickPrecision(),(double) alpha);
return(0.0);
}
break;
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
exception);
- return((MagickRealType) floor(alpha+0.5));
+ return((MagickRealType) floor(alpha));
}
if (LocaleCompare(expression,"i") == 0)
return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
{
if (LocaleCompare(expression,"j") == 0)
return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+#if defined(MAGICKCORE_HAVE_J0)
+ if (LocaleNCompare(expression,"j0",2) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
+ exception);
+ return((MagickRealType) j0((double) alpha));
+ }
+#endif
+#if defined(MAGICKCORE_HAVE_J1)
+ if (LocaleNCompare(expression,"j1",2) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
+ exception);
+ return((MagickRealType) j1((double) alpha));
+ }
+#endif
+#if defined(MAGICKCORE_HAVE_J1)
+ if (LocaleNCompare(expression,"jinc",4) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
+ exception);
+ if (alpha == 0.0)
+ return(1.0);
+ gamma=(MagickRealType) (2.0*j1((double) (MagickPI*alpha))/
+ (MagickPI*alpha));
+ return(gamma);
+ }
+#endif
break;
}
case 'L':
exception);
return((MagickRealType) log((double) alpha));
}
- if (LocaleNCompare(expression,"logtwo",4) == 0)
+ if (LocaleNCompare(expression,"logtwo",6) == 0)
{
- alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,beta,
exception);
return((MagickRealType) log10((double) alpha))/log10(2.0);
}
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
exception);
- if (alpha >= 0.0)
- return((MagickRealType) floor((double) alpha+0.5));
- return((MagickRealType) ceil((double) alpha-0.5));
+ return((MagickRealType) floor((double) alpha+0.5));
}
if (LocaleCompare(expression,"r") == 0)
return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
exception);
return(alpha < 0.0 ? -1.0 : 1.0);
}
+ if (LocaleNCompare(expression,"sinc",4) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
+ exception);
+ if (alpha == 0)
+ return(1.0);
+ gamma=(MagickRealType) (sin((double) (MagickPI*alpha))/
+ (MagickPI*alpha));
+ return(gamma);
+ }
if (LocaleNCompare(expression,"sinh",4) == 0)
{
alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
}
if (LocaleCompare(expression,"Transparent") == 0)
return(0.0);
+ if (LocaleNCompare(expression,"trunc",5) == 0)
+ {
+ alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
+ exception);
+ if (alpha >= 0.0)
+ return((MagickRealType) floor((double) alpha));
+ return((MagickRealType) ceil((double) alpha));
+ }
if (LocaleCompare(expression,"t") == 0)
return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
break;
}
MagickExport MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
- const ChannelType channel,const long x,const long y,MagickRealType *alpha,
- ExceptionInfo *exception)
+ const ChannelType channel,const ssize_t x,const ssize_t y,
+ MagickRealType *alpha,ExceptionInfo *exception)
{
MagickRealType
beta;
static FxInfo **DestroyFxThreadSet(FxInfo **fx_info)
{
- register long
+ register ssize_t
i;
assert(fx_info != (FxInfo **) NULL);
- for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+ for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
if (fx_info[i] != (FxInfo *) NULL)
fx_info[i]=DestroyFxInfo(fx_info[i]);
- fx_info=(FxInfo **) RelinquishAlignedMemory(fx_info);
+ fx_info=(FxInfo **) RelinquishMagickMemory(fx_info);
return(fx_info);
}
MagickRealType
alpha;
- register long
+ register ssize_t
i;
- unsigned long
+ size_t
number_threads;
number_threads=GetOpenMPMaximumThreads();
- fx_info=(FxInfo **) AcquireAlignedMemory(number_threads,sizeof(*fx_info));
+ fx_info=(FxInfo **) AcquireQuantumMemory(number_threads,sizeof(*fx_info));
if (fx_info == (FxInfo **) NULL)
return((FxInfo **) NULL);
(void) ResetMagickMemory(fx_info,0,number_threads*sizeof(*fx_info));
fx_expression=ConstantString(expression);
else
fx_expression=FileToString(expression+1,~0,exception);
- for (i=0; i < (long) number_threads; i++)
+ for (i=0; i < (ssize_t) number_threads; i++)
{
fx_info[i]=AcquireFxInfo(image,fx_expression);
if (fx_info[i] == (FxInfo *) NULL)
{
#define FxImageTag "Fx/Image"
+ CacheView
+ *fx_view;
+
FxInfo
- **fx_info;
+ **restrict fx_info;
Image
*fx_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickRealType
alpha;
- CacheView
- *fx_view;
+ ssize_t
+ y;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) fx_image->rows; y++)
+ for (y=0; y < (ssize_t) fx_image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickRealType
alpha;
register IndexPacket
- *__restrict fx_indexes;
+ *restrict fx_indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
continue;
}
fx_indexes=GetCacheViewAuthenticIndexQueue(fx_view);
- id=GetOpenMPThreadId();
alpha=0.0;
- for (x=0; x < (long) fx_image->columns; x++)
+ for (x=0; x < (ssize_t) fx_image->columns; x++)
{
if ((channel & RedChannel) != 0)
{
(void) FxEvaluateChannelExpression(fx_info[id],RedChannel,x,y,
&alpha,exception);
- q->red=RoundToQuantum((MagickRealType) QuantumRange*alpha);
+ q->red=ClampToQuantum((MagickRealType) QuantumRange*alpha);
}
if ((channel & GreenChannel) != 0)
{
(void) FxEvaluateChannelExpression(fx_info[id],GreenChannel,x,y,
&alpha,exception);
- q->green=RoundToQuantum((MagickRealType) QuantumRange*alpha);
+ q->green=ClampToQuantum((MagickRealType) QuantumRange*alpha);
}
if ((channel & BlueChannel) != 0)
{
(void) FxEvaluateChannelExpression(fx_info[id],BlueChannel,x,y,
&alpha,exception);
- q->blue=RoundToQuantum((MagickRealType) QuantumRange*alpha);
+ q->blue=ClampToQuantum((MagickRealType) QuantumRange*alpha);
}
if ((channel & OpacityChannel) != 0)
{
(void) FxEvaluateChannelExpression(fx_info[id],OpacityChannel,x,y,
&alpha,exception);
if (image->matte == MagickFalse)
- q->opacity=RoundToQuantum((MagickRealType) QuantumRange*alpha);
+ q->opacity=ClampToQuantum((MagickRealType) QuantumRange*alpha);
else
- q->opacity=RoundToQuantum((MagickRealType) (QuantumRange-
+ q->opacity=ClampToQuantum((MagickRealType) (QuantumRange-
QuantumRange*alpha));
}
if (((channel & IndexChannel) != 0) &&
{
(void) FxEvaluateChannelExpression(fx_info[id],IndexChannel,x,y,
&alpha,exception);
- fx_indexes[x]=(IndexPacket) RoundToQuantum((MagickRealType)
+ fx_indexes[x]=(IndexPacket) ClampToQuantum((MagickRealType)
QuantumRange*alpha);
}
q++;
{
#define ImplodeImageTag "Implode/Image"
+ CacheView
+ *image_view,
+ *implode_view;
+
Image
*implode_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickPixelPacket
zero;
scale;
ResampleFilter
- **resample_filter;
+ **restrict resample_filter;
- CacheView
- *image_view,
- *implode_view;
+ ssize_t
+ y;
/*
Initialize implode image attributes.
status=MagickTrue;
progress=0;
GetMagickPixelPacket(implode_image,&zero);
- resample_filter=AcquireResampleFilterThreadSet(image,MagickTrue,exception);
+ resample_filter=AcquireResampleFilterThreadSet(image,
+ UndefinedVirtualPixelMethod,MagickTrue,exception);
image_view=AcquireCacheView(image);
implode_view=AcquireCacheView(implode_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickPixelPacket
pixel;
delta;
register IndexPacket
- *__restrict implode_indexes;
+ *restrict implode_indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
implode_indexes=GetCacheViewAuthenticIndexQueue(implode_view);
delta.y=scale.y*(double) (y-center.y);
pixel=zero;
- id=GetOpenMPThreadId();
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
/*
Determine if the pixel is within an ellipse.
%
% The format of the MorphImage method is:
%
-% Image *MorphImages(const Image *image,const unsigned long number_frames,
+% Image *MorphImages(const Image *image,const size_t number_frames,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
MagickExport Image *MorphImages(const Image *image,
- const unsigned long number_frames,ExceptionInfo *exception)
+ const size_t number_frames,ExceptionInfo *exception)
{
#define MorphImageTag "Morph/Image"
*morph_image,
*morph_images;
- long
+ ssize_t
y;
MagickOffsetType
register const Image
*next;
- register long
+ register ssize_t
i;
MagickBooleanType
/*
Morph single image.
*/
- for (i=1; i < (long) number_frames; i++)
+ for (i=1; i < (ssize_t) number_frames; i++)
{
morph_image=CloneImage(image,0,0,MagickTrue,exception);
if (morph_image == (Image *) NULL)
return((Image *) NULL);
}
AppendImageToList(&morph_images,morph_image);
- if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
- (QuantumTick(i,number_frames) != MagickFalse))
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
- status=image->progress_monitor(MorphImageTag,i,number_frames,
- image->client_data);
- if (status == MagickFalse)
- break;
+ MagickBooleanType
+ proceed;
+
+ proceed=SetImageProgress(image,MorphImageTag,(MagickOffsetType) i,
+ number_frames);
+ if (proceed == MagickFalse)
+ status=MagickFalse;
}
}
return(GetFirstImageInList(morph_images));
next=image;
for ( ; GetNextImageInList(next) != (Image *) NULL; next=GetNextImageInList(next))
{
- for (i=0; i < (long) number_frames; i++)
+ for (i=0; i < (ssize_t) number_frames; i++)
{
CacheView
*image_view,
beta=(MagickRealType) (i+1.0)/(MagickRealType) (number_frames+1.0);
alpha=1.0-beta;
- morph_image=ZoomImage(next,(unsigned long) (alpha*next->columns+beta*
- GetNextImageInList(next)->columns+0.5),(unsigned long) (alpha*
- next->rows+beta*GetNextImageInList(next)->rows+0.5),exception);
+ morph_image=ResizeImage(next,(size_t) (alpha*next->columns+beta*
+ GetNextImageInList(next)->columns+0.5),(size_t) (alpha*
+ next->rows+beta*GetNextImageInList(next)->rows+0.5),
+ next->filter,next->blur,exception);
if (morph_image == (Image *) NULL)
{
morph_images=DestroyImageList(morph_images);
}
AppendImageToList(&morph_images,morph_image);
morph_images=GetLastImageInList(morph_images);
- morph_image=ZoomImage(GetNextImageInList(next),morph_images->columns,
- morph_images->rows,exception);
+ morph_image=ResizeImage(GetNextImageInList(next),morph_images->columns,
+ morph_images->rows,GetNextImageInList(next)->filter,
+ GetNextImageInList(next)->blur,exception);
if (morph_image == (Image *) NULL)
{
morph_images=DestroyImageList(morph_images);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(status)
#endif
- for (y=0; y < (long) morph_images->rows; y++)
+ for (y=0; y < (ssize_t) morph_images->rows; y++)
{
MagickBooleanType
sync;
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) morph_images->columns; x++)
+ for (x=0; x < (ssize_t) morph_images->columns; x++)
{
- q->red=RoundToQuantum(alpha*q->red+beta*p->red);
- q->green=RoundToQuantum(alpha*q->green+beta*p->green);
- q->blue=RoundToQuantum(alpha*q->blue+beta*p->blue);
- q->opacity=RoundToQuantum(alpha*q->opacity+beta*p->opacity);
+ q->red=ClampToQuantum(alpha*q->red+beta*GetRedPixelComponent(p));
+ q->green=ClampToQuantum(alpha*q->green+beta*
+ GetGreenPixelComponent(p));
+ q->blue=ClampToQuantum(alpha*q->blue+beta*GetBluePixelComponent(p));
+ q->opacity=ClampToQuantum(alpha*q->opacity+beta*
+ GetOpacityPixelComponent(p));
p++;
q++;
}
image_view=DestroyCacheView(image_view);
morph_image=DestroyImage(morph_image);
}
- if (i < (long) number_frames)
+ if (i < (ssize_t) number_frames)
break;
/*
Clone last frame in sequence.
% The format of the PlasmaImage method is:
%
% MagickBooleanType PlasmaImage(Image *image,const SegmentInfo *segment,
-% unsigned long attenuate,unsigned long depth)
+% size_t attenuate,size_t depth)
%
% A description of each parameter follows:
%
%
% o segment: Define the region to apply plasma fractals values.
%
-% o attenuate: Define the plasmattenuation factor.
+% o attenuate: Define the plasma attenuation factor.
%
% o depth: Limit the plasma recursion depth.
%
Quantum
plasma;
- plasma=RoundToQuantum(pixel+noise*GetPseudoRandomValue(random_info)-
+ plasma=ClampToQuantum(pixel+noise*GetPseudoRandomValue(random_info)-
noise/2.0);
return(plasma);
}
MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
- RandomInfo *random_info,const SegmentInfo *segment,unsigned long attenuate,
- unsigned long depth)
+ CacheView *image_view,RandomInfo *random_info,const SegmentInfo *segment,
+ size_t attenuate,size_t depth)
{
ExceptionInfo
*exception;
- long
+ ssize_t
x,
x_mid,
y,
*/
depth--;
attenuate++;
- x_mid=(long) (segment->x1+segment->x2+0.5)/2;
- y_mid=(long) (segment->y1+segment->y2+0.5)/2;
+ x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
+ y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
local_info=(*segment);
local_info.x2=(double) x_mid;
local_info.y2=(double) y_mid;
- (void) PlasmaImageProxy(image,random_info,&local_info,attenuate,depth);
+ (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
+ attenuate,depth);
local_info=(*segment);
local_info.y1=(double) y_mid;
local_info.x2=(double) x_mid;
- (void) PlasmaImageProxy(image,random_info,&local_info,attenuate,depth);
+ (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
+ attenuate,depth);
local_info=(*segment);
local_info.x1=(double) x_mid;
local_info.y2=(double) y_mid;
- (void) PlasmaImageProxy(image,random_info,&local_info,attenuate,depth);
+ (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
+ attenuate,depth);
local_info=(*segment);
local_info.x1=(double) x_mid;
local_info.y1=(double) y_mid;
- return(PlasmaImageProxy(image,random_info,&local_info,attenuate,depth));
+ return(PlasmaImageProxy(image,image_view,random_info,&local_info,
+ attenuate,depth));
}
- if (SetImageStorageClass(image,DirectClass) == MagickFalse)
- return(MagickFalse);
- x_mid=(long) (segment->x1+segment->x2+0.5)/2;
- y_mid=(long) (segment->y1+segment->y2+0.5)/2;
+ x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
+ y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
if ((segment->x1 == (double) x_mid) && (segment->x2 == (double) x_mid) &&
(segment->y1 == (double) y_mid) && (segment->y2 == (double) y_mid))
return(MagickFalse);
if ((segment->x1 != (double) x_mid) || (segment->x2 != (double) x_mid))
{
register PixelPacket
- *__restrict q;
+ *restrict q;
/*
Left pixel.
*/
- x=(long) (segment->x1+0.5);
- (void) GetOneVirtualPixel(image,x,(long) (segment->y1+0.5),&u,exception);
- (void) GetOneVirtualPixel(image,x,(long) (segment->y2+0.5),&v,exception);
- q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
+ x=(ssize_t) ceil(segment->x1-0.5);
+ (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
+ ceil(segment->y1-0.5),&u,exception);
+ (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
+ ceil(segment->y2-0.5),&v,exception);
+ q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
if (q == (PixelPacket *) NULL)
return(MagickTrue);
q->red=PlasmaPixel(random_info,(MagickRealType) (u.red+v.red)/2.0,
plasma);
q->blue=PlasmaPixel(random_info,(MagickRealType) (u.blue+v.blue)/2.0,
plasma);
- (void) SyncAuthenticPixels(image,exception);
+ (void) SyncCacheViewAuthenticPixels(image_view,exception);
if (segment->x1 != segment->x2)
{
/*
Right pixel.
*/
- x=(long) (segment->x2+0.5);
- (void) GetOneVirtualPixel(image,x,(long) (segment->y1+0.5),&u,
- exception);
- (void) GetOneVirtualPixel(image,x,(long) (segment->y2+0.5),&v,
- exception);
- q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
+ x=(ssize_t) ceil(segment->x2-0.5);
+ (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
+ ceil(segment->y1-0.5),&u,exception);
+ (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
+ ceil(segment->y2-0.5),&v,exception);
+ q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
if (q == (PixelPacket *) NULL)
return(MagickTrue);
q->red=PlasmaPixel(random_info,(MagickRealType) (u.red+v.red)/2.0,
q->green=PlasmaPixel(random_info,(MagickRealType) (u.green+v.green)/
2.0,plasma);
q->blue=PlasmaPixel(random_info,(MagickRealType) (u.blue+v.blue)/2.0,
- plasma);
- (void) SyncAuthenticPixels(image,exception);
+ plasma);
+ (void) SyncCacheViewAuthenticPixels(image_view,exception);
}
}
if ((segment->y1 != (double) y_mid) || (segment->y2 != (double) y_mid))
if ((segment->x1 != (double) x_mid) || (segment->y2 != (double) y_mid))
{
register PixelPacket
- *__restrict q;
+ *restrict q;
/*
Bottom pixel.
*/
- y=(long) (segment->y2+0.5);
- (void) GetOneVirtualPixel(image,(long) (segment->x1+0.5),y,&u,
- exception);
- (void) GetOneVirtualPixel(image,(long) (segment->x2+0.5),y,&v,
- exception);
- q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
+ y=(ssize_t) ceil(segment->y2-0.5);
+ (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
+ ceil(segment->x1-0.5),y,&u,exception);
+ (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
+ ceil(segment->x2-0.5),y,&v,exception);
+ q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
if (q == (PixelPacket *) NULL)
return(MagickTrue);
q->red=PlasmaPixel(random_info,(MagickRealType) (u.red+v.red)/2.0,
2.0,plasma);
q->blue=PlasmaPixel(random_info,(MagickRealType) (u.blue+v.blue)/2.0,
plasma);
- (void) SyncAuthenticPixels(image,exception);
+ (void) SyncCacheViewAuthenticPixels(image_view,exception);
}
if (segment->y1 != segment->y2)
{
register PixelPacket
- *__restrict q;
+ *restrict q;
/*
Top pixel.
*/
- y=(long) (segment->y1+0.5);
- (void) GetOneVirtualPixel(image,(long) (segment->x1+0.5),y,&u,
- exception);
- (void) GetOneVirtualPixel(image,(long) (segment->x2+0.5),y,&v,
- exception);
- q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
+ y=(ssize_t) ceil(segment->y1-0.5);
+ (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
+ ceil(segment->x1-0.5),y,&u,exception);
+ (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
+ ceil(segment->x2-0.5),y,&v,exception);
+ q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
if (q == (PixelPacket *) NULL)
return(MagickTrue);
q->red=PlasmaPixel(random_info,(MagickRealType) (u.red+v.red)/2.0,
2.0,plasma);
q->blue=PlasmaPixel(random_info,(MagickRealType) (u.blue+v.blue)/2.0,
plasma);
- (void) SyncAuthenticPixels(image,exception);
+ (void) SyncCacheViewAuthenticPixels(image_view,exception);
}
}
if ((segment->x1 != segment->x2) || (segment->y1 != segment->y2))
{
register PixelPacket
- *__restrict q;
+ *restrict q;
/*
Middle pixel.
*/
- x=(long) (segment->x1+0.5);
- y=(long) (segment->y1+0.5);
+ x=(ssize_t) ceil(segment->x1-0.5);
+ y=(ssize_t) ceil(segment->y1-0.5);
(void) GetOneVirtualPixel(image,x,y,&u,exception);
- x=(long) (segment->x2+0.5);
- y=(long) (segment->y2+0.5);
- (void) GetOneVirtualPixel(image,x,y,&v,exception);
- q=QueueAuthenticPixels(image,x_mid,y_mid,1,1,exception);
+ x=(ssize_t) ceil(segment->x2-0.5);
+ y=(ssize_t) ceil(segment->y2-0.5);
+ (void) GetOneCacheViewVirtualPixel(image_view,x,y,&v,exception);
+ q=QueueCacheViewAuthenticPixels(image_view,x_mid,y_mid,1,1,exception);
if (q == (PixelPacket *) NULL)
return(MagickTrue);
q->red=PlasmaPixel(random_info,(MagickRealType) (u.red+v.red)/2.0,
plasma);
q->blue=PlasmaPixel(random_info,(MagickRealType) (u.blue+v.blue)/2.0,
plasma);
- (void) SyncAuthenticPixels(image,exception);
+ (void) SyncCacheViewAuthenticPixels(image_view,exception);
}
if (((segment->x2-segment->x1) < 3.0) && ((segment->y2-segment->y1) < 3.0))
return(MagickTrue);
}
\f
MagickExport MagickBooleanType PlasmaImage(Image *image,
- const SegmentInfo *segment,unsigned long attenuate,unsigned long depth)
+ const SegmentInfo *segment,size_t attenuate,size_t depth)
{
+ CacheView
+ *image_view;
+
MagickBooleanType
status;
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
+ if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+ return(MagickFalse);
+ image_view=AcquireCacheView(image);
random_info=AcquireRandomInfo();
- status=PlasmaImageProxy(image,random_info,segment,attenuate,depth);
+ status=PlasmaImageProxy(image,image_view,random_info,segment,attenuate,depth);
random_info=DestroyRandomInfo(random_info);
+ image_view=DestroyCacheView(image_view);
return(status);
}
\f
const char
*value;
- long
+ ssize_t
quantum;
Image
*rotate_image,
*trim_image;
- unsigned long
+ size_t
height;
/*
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- quantum=(long) MagickMax(MagickMax((double) image->columns,(double)
+ quantum=(ssize_t) MagickMax(MagickMax((double) image->columns,(double)
image->rows)/25.0,10.0);
height=image->rows+2*quantum;
caption_image=(Image *) NULL;
DrawInfo
*annotate_info;
- long
+ ssize_t
count;
MagickBooleanType
caption=InterpretImageProperties((ImageInfo *) NULL,(Image *) image,
value);
(void) CloneString(&annotate_info->text,caption);
- count=FormatMagickCaption(caption_image,annotate_info,&metrics,&caption);
- status=SetImageExtent(caption_image,image->columns,(unsigned long)
+ count=FormatMagickCaption(caption_image,annotate_info,MagickTrue,&metrics,
+ &caption);
+ status=SetImageExtent(caption_image,image->columns,(size_t)
((count+1)*(metrics.ascent-metrics.descent)+0.5));
if (status == MagickFalse)
caption_image=DestroyImage(caption_image);
if (caption_image != (Image *) NULL)
{
(void) CompositeImage(picture_image,OverCompositeOp,caption_image,
- quantum,(long) (image->rows+3*quantum/2));
+ quantum,(ssize_t) (image->rows+3*quantum/2));
caption_image=DestroyImage(caption_image);
}
(void) QueryColorDatabase("none",&picture_image->background_color,exception);
picture_image=rotate_image;
bend_image=WaveImage(picture_image,0.01*picture_image->rows,2.0*
picture_image->columns,exception);
- picture_image=DestroyImage(picture_image);
- if (bend_image == (Image *) NULL)
- return((Image *) NULL);
- InheritException(&bend_image->exception,exception);
- picture_image=bend_image;
- rotate_image=RotateImage(picture_image,-90.0,exception);
- picture_image=DestroyImage(picture_image);
- if (rotate_image == (Image *) NULL)
- return((Image *) NULL);
- picture_image=rotate_image;
- picture_image->background_color=image->background_color;
- polaroid_image=ShadowImage(picture_image,80.0,2.0,quantum/3,quantum/3,
- exception);
- if (polaroid_image == (Image *) NULL)
- {
- picture_image=DestroyImage(picture_image);
- return(picture_image);
- }
- flop_image=FlopImage(polaroid_image,exception);
- polaroid_image=DestroyImage(polaroid_image);
- if (flop_image == (Image *) NULL)
- {
- picture_image=DestroyImage(picture_image);
- return(picture_image);
- }
- polaroid_image=flop_image;
- (void) CompositeImage(polaroid_image,OverCompositeOp,picture_image,
- (long) (-0.01*picture_image->columns/2.0),0L);
- picture_image=DestroyImage(picture_image);
- (void) QueryColorDatabase("none",&polaroid_image->background_color,exception);
- rotate_image=RotateImage(polaroid_image,angle,exception);
- polaroid_image=DestroyImage(polaroid_image);
- if (rotate_image == (Image *) NULL)
- return((Image *) NULL);
- polaroid_image=rotate_image;
- trim_image=TrimImage(polaroid_image,exception);
- polaroid_image=DestroyImage(polaroid_image);
- if (trim_image == (Image *) NULL)
- return((Image *) NULL);
- polaroid_image=trim_image;
- return(polaroid_image);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% R e c o l o r I m a g e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% RecolorImage() translate, scale, shear, or rotate image colors. Although
-% you can use variable sized matrices, typically you use a 5 x 5 for an RGBA
-% image and a 6x6 for CMYKA. Populate the last row with normalized values to
-% translate.
-%
-% The format of the RecolorImage method is:
-%
-% Image *RecolorImage(const Image *image,const unsigned long order,
-% const double *color_matrix,ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-% o order: the number of columns and rows in the recolor matrix.
-%
-% o color_matrix: An array of double representing the recolor matrix.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-MagickExport Image *RecolorImage(const Image *image,const unsigned long order,
- const double *color_matrix,ExceptionInfo *exception)
-{
-#define RecolorImageTag "Recolor/Image"
-
- Image
- *recolor_image;
-
- long
- progress,
- y;
-
- MagickBooleanType
- status;
-
- MagickPixelPacket
- zero;
-
- CacheView
- *image_view,
- *recolor_view;
-
- /*
- Initialize image attributes.
- */
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- recolor_image=CloneImage(image,image->columns,image->rows,MagickTrue,
- exception);
- if (recolor_image == (Image *) NULL)
+ picture_image=DestroyImage(picture_image);
+ if (bend_image == (Image *) NULL)
return((Image *) NULL);
- if (SetImageStorageClass(recolor_image,DirectClass) == MagickFalse)
- {
- InheritException(exception,&recolor_image->exception);
- recolor_image=DestroyImage(recolor_image);
- return((Image *) NULL);
- }
- if (image->debug != MagickFalse)
+ InheritException(&bend_image->exception,exception);
+ picture_image=bend_image;
+ rotate_image=RotateImage(picture_image,-90.0,exception);
+ picture_image=DestroyImage(picture_image);
+ if (rotate_image == (Image *) NULL)
+ return((Image *) NULL);
+ picture_image=rotate_image;
+ picture_image->background_color=image->background_color;
+ polaroid_image=ShadowImage(picture_image,80.0,2.0,quantum/3,quantum/3,
+ exception);
+ if (polaroid_image == (Image *) NULL)
{
- char
- format[MaxTextExtent],
- *message;
-
- long
- u,
- v;
-
- register const double
- *k;
-
- (void) LogMagickEvent(TransformEvent,GetMagickModule(),
- " Recolor image with %ldx%ld color matrix:",order,order);
- message=AcquireString("");
- k=color_matrix;
- for (v=0; v < (long) order; v++)
- {
- *message='\0';
- (void) FormatMagickString(format,MaxTextExtent,"%ld: ",v);
- (void) ConcatenateString(&message,format);
- for (u=0; u < (long) order; u++)
- {
- (void) FormatMagickString(format,MaxTextExtent,"%+f ",*k++);
- (void) ConcatenateString(&message,format);
- }
- (void) LogMagickEvent(TransformEvent,GetMagickModule(),"%s",message);
- }
- message=DestroyString(message);
+ picture_image=DestroyImage(picture_image);
+ return(picture_image);
}
- /*
- Recolor image.
- */
- status=MagickTrue;
- progress=0;
- GetMagickPixelPacket(image,&zero);
- image_view=AcquireCacheView(image);
- recolor_view=AcquireCacheView(recolor_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
-#endif
- for (y=0; y < (long) image->rows; y++)
- {
- MagickPixelPacket
- pixel,
- recolor_pixel;
-
- register const double
- *k;
-
- register const IndexPacket
- *__restrict indexes;
-
- register const PixelPacket
- *__restrict p;
-
- register long
- x;
-
- register IndexPacket
- *__restrict recolor_indexes;
-
- register PixelPacket
- *__restrict q;
-
- if (status == MagickFalse)
- continue;
- p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
- q=QueueCacheViewAuthenticPixels(recolor_view,0,y,recolor_image->columns,1,
- exception);
- if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
- {
- status=MagickFalse;
- continue;
- }
- indexes=GetCacheViewAuthenticIndexQueue(image_view);
- recolor_indexes=GetCacheViewAuthenticIndexQueue(recolor_view);
- pixel=zero;
- recolor_pixel=zero;
- k=color_matrix;
- for (x=0; x < (long) image->columns; x++)
+ flop_image=FlopImage(polaroid_image,exception);
+ polaroid_image=DestroyImage(polaroid_image);
+ if (flop_image == (Image *) NULL)
{
- SetMagickPixelPacket(image,p,indexes,&pixel);
- SetMagickPixelPacket(recolor_image,p,indexes,&recolor_pixel);
- switch (order)
- {
- case 0:
- break;
- case 1:
- {
- recolor_pixel.red=k[0]*pixel.red;
- break;
- }
- case 2:
- {
- recolor_pixel.red=k[0]*pixel.red+k[1]*pixel.green;
- recolor_pixel.green=k[2]*pixel.red+k[3]*pixel.green;
- break;
- }
- case 3:
- {
- recolor_pixel.red=k[0]*pixel.red+k[1]*pixel.green+k[2]*pixel.blue;
- recolor_pixel.green=k[3]*pixel.red+k[4]*pixel.green+k[5]*pixel.blue;
- recolor_pixel.blue=k[6]*pixel.red+k[7]*pixel.green+k[8]*pixel.blue;
- break;
- }
- case 4:
- {
- recolor_pixel.red=k[0]*pixel.red+k[1]*pixel.green+k[2]*pixel.blue+
- k[12]*QuantumRange;
- recolor_pixel.green=k[4]*pixel.red+k[5]*pixel.green+k[6]*pixel.blue+
- k[13]*QuantumRange;
- recolor_pixel.blue=k[8]*pixel.red+k[9]*pixel.green+k[10]*pixel.blue+
- k[14]*QuantumRange;
- break;
- }
- case 5:
- {
- recolor_pixel.red=k[0]*pixel.red+k[1]*pixel.green+k[2]*pixel.blue+
- k[3]*(QuantumRange-pixel.opacity)+k[20]*QuantumRange;
- recolor_pixel.green=k[5]*pixel.red+k[6]*pixel.green+k[7]*pixel.blue+
- k[8]*(QuantumRange-pixel.opacity)+k[21]*QuantumRange;
- recolor_pixel.blue=k[10]*pixel.red+k[11]*pixel.green+k[12]*pixel.blue+
- k[13]*(QuantumRange-pixel.opacity)+k[22]*QuantumRange;
- recolor_pixel.opacity=(MagickRealType) QuantumRange-(k[15]*pixel.red+
- k[16]*pixel.green+k[17]*pixel.blue+k[18]*(QuantumRange-
- pixel.opacity)+k[23]*QuantumRange);
- break;
- }
- default:
- {
- recolor_pixel.red=k[0]*pixel.red+k[1]*pixel.green+k[2]*pixel.blue+
- k[3]*pixel.index+k[4]*((Quantum) QuantumRange-pixel.opacity)+
- k[30]*QuantumRange;
- recolor_pixel.green=k[6]*pixel.red+k[7]*pixel.green+k[8]*pixel.blue+
- k[9]*pixel.index+k[10]*((Quantum) QuantumRange-pixel.opacity)+
- k[31]*QuantumRange;
- recolor_pixel.blue=k[12]*pixel.red+k[13]*pixel.green+k[14]*pixel.blue+
- k[15]*pixel.index+k[16]*((Quantum) QuantumRange-pixel.opacity)+
- k[32]*QuantumRange;
- if (image->colorspace == CMYKColorspace)
- recolor_pixel.index=k[18]*pixel.red+k[19]*pixel.green+k[20]*
- pixel.blue+k[21]*pixel.index+k[22]*((Quantum) QuantumRange-
- pixel.opacity)+k[33]*QuantumRange;
- recolor_pixel.opacity=(MagickRealType) QuantumRange-(k[24]*pixel.red+
- k[25]*pixel.green+k[26]*pixel.blue+k[27]*pixel.index+k[28]*
- (QuantumRange-pixel.opacity)+k[34]*QuantumRange);
- break;
- }
- }
- q->red=RoundToQuantum(recolor_pixel.red);
- q->green=RoundToQuantum(recolor_pixel.green);
- q->blue=RoundToQuantum(recolor_pixel.blue);
- q->opacity=RoundToQuantum(recolor_pixel.opacity);
- if (image->colorspace == CMYKColorspace)
- recolor_indexes[x]=RoundToQuantum(recolor_pixel.index);
- p++;
- q++;
+ picture_image=DestroyImage(picture_image);
+ return(picture_image);
}
- if (SyncCacheViewAuthenticPixels(recolor_view,exception) == MagickFalse)
- status=MagickFalse;
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_RecolorImage)
-#endif
- proceed=SetImageProgress(image,RecolorImageTag,progress++,image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- recolor_view=DestroyCacheView(recolor_view);
- image_view=DestroyCacheView(image_view);
- if (status == MagickFalse)
- recolor_image=DestroyImage(recolor_image);
- return(recolor_image);
+ polaroid_image=flop_image;
+ (void) CompositeImage(polaroid_image,OverCompositeOp,picture_image,
+ (ssize_t) (-0.01*picture_image->columns/2.0),0L);
+ picture_image=DestroyImage(picture_image);
+ (void) QueryColorDatabase("none",&polaroid_image->background_color,exception);
+ rotate_image=RotateImage(polaroid_image,angle,exception);
+ polaroid_image=DestroyImage(polaroid_image);
+ if (rotate_image == (Image *) NULL)
+ return((Image *) NULL);
+ polaroid_image=rotate_image;
+ trim_image=TrimImage(polaroid_image,exception);
+ polaroid_image=DestroyImage(polaroid_image);
+ if (trim_image == (Image *) NULL)
+ return((Image *) NULL);
+ polaroid_image=trim_image;
+ return(polaroid_image);
}
\f
/*
{
#define SepiaToneImageTag "SepiaTone/Image"
+ CacheView
+ *image_view,
+ *sepia_view;
+
Image
*sepia_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
- CacheView
- *image_view,
- *sepia_view;
+ MagickOffsetType
+ progress;
+
+ ssize_t
+ y;
/*
Initialize sepia-toned image attributes.
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
MagickRealType
intensity,
intensity=(MagickRealType) PixelIntensityToQuantum(p);
tone=intensity > threshold ? (MagickRealType) QuantumRange : intensity+
(MagickRealType) QuantumRange-threshold;
- q->red=RoundToQuantum(tone);
+ q->red=ClampToQuantum(tone);
tone=intensity > (7.0*threshold/6.0) ? (MagickRealType) QuantumRange :
intensity+(MagickRealType) QuantumRange-7.0*threshold/6.0;
- q->green=RoundToQuantum(tone);
+ q->green=ClampToQuantum(tone);
tone=intensity < (threshold/6.0) ? 0 : intensity-threshold/6.0;
- q->blue=RoundToQuantum(tone);
+ q->blue=ClampToQuantum(tone);
tone=threshold/7.0;
if ((MagickRealType) q->green < tone)
- q->green=RoundToQuantum(tone);
+ q->green=ClampToQuantum(tone);
if ((MagickRealType) q->blue < tone)
- q->blue=RoundToQuantum(tone);
+ q->blue=ClampToQuantum(tone);
p++;
q++;
}
% The format of the ShadowImage method is:
%
% Image *ShadowImage(const Image *image,const double opacity,
-% const double sigma,const long x_offset,const long y_offset,
+% const double sigma,const ssize_t x_offset,const ssize_t y_offset,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
MagickExport Image *ShadowImage(const Image *image,const double opacity,
- const double sigma,const long x_offset,const long y_offset,
+ const double sigma,const ssize_t x_offset,const ssize_t y_offset,
ExceptionInfo *exception)
{
#define ShadowImageTag "Shadow/Image"
+ CacheView
+ *image_view;
+
Image
*border_image,
*clone_image,
*shadow_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
RectangleInfo
border_info;
- CacheView
- *image_view;
+ ssize_t
+ y;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
return((Image *) NULL);
(void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod);
clone_image->compose=OverCompositeOp;
- border_info.width=(unsigned long) (2.0*sigma+0.5);
- border_info.height=(unsigned long) (2.0*sigma+0.5);
+ border_info.width=(size_t) floor(2.0*sigma+0.5);
+ border_info.height=(size_t) floor(2.0*sigma+0.5);
border_info.x=0;
border_info.y=0;
(void) QueryColorDatabase("none",&clone_image->border_color,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) border_image->rows; y++)
+ for (y=0; y < (ssize_t) border_image->rows; y++)
{
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) border_image->columns; x++)
+ for (x=0; x < (ssize_t) border_image->columns; x++)
{
q->red=border_image->background_color.red;
q->green=border_image->background_color.green;
if (border_image->matte == MagickFalse)
q->opacity=border_image->background_color.opacity;
else
- q->opacity=RoundToQuantum((MagickRealType) (QuantumRange-(QuantumRange-
- q->opacity)*opacity/100.0));
+ q->opacity=ClampToQuantum((MagickRealType) (QuantumRange-
+ GetAlphaPixelComponent(q)*opacity/100.0));
q++;
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
shadow_image->page.width=shadow_image->columns;
if (shadow_image->page.height == 0)
shadow_image->page.height=shadow_image->rows;
- shadow_image->page.width+=x_offset-(long) border_info.width;
- shadow_image->page.height+=y_offset-(long) border_info.height;
- shadow_image->page.x+=x_offset-(long) border_info.width;
- shadow_image->page.y+=y_offset-(long) border_info.height;
+ shadow_image->page.width+=x_offset-(ssize_t) border_info.width;
+ shadow_image->page.height+=y_offset-(ssize_t) border_info.height;
+ shadow_image->page.x+=x_offset-(ssize_t) border_info.width;
+ shadow_image->page.y+=y_offset-(ssize_t) border_info.height;
return(shadow_image);
}
\f
MagickExport Image *SketchImage(const Image *image,const double radius,
const double sigma,const double angle,ExceptionInfo *exception)
{
+ CacheView
+ *random_view;
+
Image
*blend_image,
*blur_image,
*random_image,
*sketch_image;
- long
+ ssize_t
y;
MagickBooleanType
zero;
RandomInfo
- *random_info;
-
- CacheView
- *random_view;
+ **restrict random_info;
/*
Sketch image.
return((Image *) NULL);
status=MagickTrue;
GetMagickPixelPacket(random_image,&zero);
- random_info=AcquireRandomInfo();
+ random_info=AcquireRandomInfoThreadSet();
random_view=AcquireCacheView(random_image);
- for (y=0; y < (long) random_image->rows; y++)
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp parallel for schedule(dynamic,4) shared(status)
+#endif
+ for (y=0; y < (ssize_t) random_image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickPixelPacket
pixel;
register IndexPacket
- *__restrict indexes;
+ *restrict indexes;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
+ if (status == MagickFalse)
+ continue;
q=QueueCacheViewAuthenticPixels(random_view,0,y,random_image->columns,1,
exception);
if (q == (PixelPacket *) NULL)
}
indexes=GetCacheViewAuthenticIndexQueue(random_view);
pixel=zero;
- for (x=0; x < (long) random_image->columns; x++)
+ for (x=0; x < (ssize_t) random_image->columns; x++)
{
pixel.red=(MagickRealType) (QuantumRange*
- GetPseudoRandomValue(random_info));
+ GetPseudoRandomValue(random_info[id]));
pixel.green=pixel.red;
pixel.blue=pixel.red;
if (image->colorspace == CMYKColorspace)
}
if (SyncCacheViewAuthenticPixels(random_view,exception) == MagickFalse)
status=MagickFalse;
- if (status == MagickFalse)
- break;
}
random_view=DestroyCacheView(random_view);
- random_info=DestroyRandomInfo(random_info);
+ random_info=DestroyRandomInfoThreadSet(random_info);
if (status == MagickFalse)
{
random_image=DestroyImage(random_image);
{
#define SolarizeImageTag "Solarize/Image"
+ CacheView
+ *image_view;
+
ExceptionInfo
*exception;
- long
- progress,
- y;
-
MagickBooleanType
status;
- CacheView
- *image_view;
+ MagickOffsetType
+ progress;
+
+ ssize_t
+ y;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->storage_class == PseudoClass)
{
- register long
+ register ssize_t
i;
/*
Solarize colormap.
*/
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
if ((MagickRealType) image->colormap[i].red > threshold)
image->colormap[i].red=(Quantum) QuantumRange-image->colormap[i].red;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
if ((MagickRealType) q->red > threshold)
q->red=(Quantum) QuantumRange-q->red;
MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
ExceptionInfo *exception)
{
-#define GetBit(alpha,i) ((((unsigned long) (alpha) >> (unsigned long) \
- (i)) & 0x01) != 0)
-#define SetBit(alpha,i,set) (alpha)=(Quantum) ((set) ? (unsigned long) (alpha) \
- | (1UL << (unsigned long) (i)) : (unsigned long) (alpha) & \
- ~(1UL << (unsigned long) (i)))
+#define GetBit(alpha,i) ((((size_t) (alpha) >> (size_t) (i)) & 0x01) != 0)
+#define SetBit(alpha,i,set) (alpha)=(Quantum) ((set) != 0 ? (size_t) (alpha) \
+ | (one << (size_t) (i)) : (size_t) (alpha) & ~(one << (size_t) (i)))
#define SteganoImageTag "Stegano/Image"
+ CacheView
+ *stegano_view,
+ *watermark_view;
+
Image
*stegano_image;
int
c;
- long
- i,
- j,
- k,
- y;
-
MagickBooleanType
status;
PixelPacket
pixel;
- register long
- x;
-
register PixelPacket
*q;
- unsigned long
- depth;
+ register ssize_t
+ x;
+
+ size_t
+ depth,
+ one;
+
+ ssize_t
+ i,
+ j,
+ k,
+ y;
/*
Initialize steganographic image attributes.
assert(watermark->signature == MagickSignature);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
+ one=1UL;
stegano_image=CloneImage(image,0,0,MagickTrue,exception);
if (stegano_image == (Image *) NULL)
return((Image *) NULL);
j=0;
depth=stegano_image->depth;
k=image->offset;
- for (i=(long) depth-1; (i >= 0) && (j < (long) depth); i--)
+ watermark_view=AcquireCacheView(watermark);
+ stegano_view=AcquireCacheView(stegano_image);
+ for (i=(ssize_t) depth-1; (i >= 0) && (j < (ssize_t) depth); i--)
{
- for (y=0; (y < (long) watermark->rows) && (j < (long) depth); y++)
+ for (y=0; (y < (ssize_t) watermark->rows) && (j < (ssize_t) depth); y++)
{
- for (x=0; (x < (long) watermark->columns) && (j < (long) depth); x++)
+ for (x=0; (x < (ssize_t) watermark->columns) && (j < (ssize_t) depth); x++)
{
- (void) GetOneVirtualPixel(watermark,x,y,&pixel,exception);
- if ((k/(long) stegano_image->columns) >= (long) stegano_image->rows)
+ (void) GetOneCacheViewVirtualPixel(watermark_view,x,y,&pixel,exception);
+ if ((k/(ssize_t) stegano_image->columns) >= (ssize_t) stegano_image->rows)
break;
- q=GetAuthenticPixels(stegano_image,k % (long) stegano_image->columns,
- k/(long) stegano_image->columns,1,1,exception);
+ q=GetCacheViewAuthenticPixels(stegano_view,k % (ssize_t)
+ stegano_image->columns,k/(ssize_t) stegano_image->columns,1,1,
+ exception);
if (q == (PixelPacket *) NULL)
break;
switch (c)
break;
}
}
- if (SyncAuthenticPixels(stegano_image,exception) == MagickFalse)
+ if (SyncCacheViewAuthenticPixels(stegano_view,exception) == MagickFalse)
break;
c++;
if (c == 3)
c=0;
k++;
- if (k == (long) (stegano_image->columns*stegano_image->columns))
+ if (k == (ssize_t) (stegano_image->columns*stegano_image->columns))
k=0;
if (k == image->offset)
j++;
}
}
- if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
- (QuantumTick((MagickOffsetType) depth-i,depth) != MagickFalse))
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
- status=image->progress_monitor(SteganoImageTag,(MagickOffsetType) depth-
- i,depth,image->client_data);
- if (status == MagickFalse)
- break;
+ MagickBooleanType
+ proceed;
+
+ proceed=SetImageProgress(image,SteganoImageTag,(MagickOffsetType)
+ (depth-i),depth);
+ if (proceed == MagickFalse)
+ status=MagickFalse;
}
}
+ stegano_view=DestroyCacheView(stegano_view);
+ watermark_view=DestroyCacheView(watermark_view);
if (stegano_image->storage_class == PseudoClass)
(void) SyncImage(stegano_image);
return(stegano_image);
% Image *StereoImage(const Image *left_image,const Image *right_image,
% ExceptionInfo *exception)
% Image *StereoAnaglyphImage(const Image *left_image,
-% const Image *right_image,const long x_offset,const long y_offset,
+% const Image *right_image,const ssize_t x_offset,const ssize_t y_offset,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
}
MagickExport Image *StereoAnaglyphImage(const Image *left_image,
- const Image *right_image,const long x_offset,const long y_offset,
+ const Image *right_image,const ssize_t x_offset,const ssize_t y_offset,
ExceptionInfo *exception)
{
#define StereoImageTag "Stereo/Image"
Image
*stereo_image;
- long
+ ssize_t
y;
MagickBooleanType
/*
Copy left image to red channel and right image to blue channel.
*/
- for (y=0; y < (long) stereo_image->rows; y++)
+ for (y=0; y < (ssize_t) stereo_image->rows; y++)
{
register const PixelPacket
- *__restrict p,
- *__restrict q;
+ *restrict p,
+ *restrict q;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict r;
+ *restrict r;
p=GetVirtualPixels(left_image,-x_offset,y-y_offset,image->columns,1,
exception);
if ((p == (PixelPacket *) NULL) || (q == (PixelPacket *) NULL) ||
(r == (PixelPacket *) NULL))
break;
- for (x=0; x < (long) stereo_image->columns; x++)
+ for (x=0; x < (ssize_t) stereo_image->columns; x++)
{
- r->red=p->red;
+ r->red=GetRedPixelComponent(p);
r->green=q->green;
r->blue=q->blue;
r->opacity=(Quantum) ((p->opacity+q->opacity)/2);
}
if (SyncAuthenticPixels(stereo_image,exception) == MagickFalse)
break;
- if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
- (QuantumTick(y,image->rows) != MagickFalse))
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
- status=image->progress_monitor(StereoImageTag,y,stereo_image->rows,
- stereo_image->client_data);
- if (status == MagickFalse)
- break;
+ MagickBooleanType
+ proceed;
+
+ proceed=SetImageProgress(image,StereoImageTag,(MagickOffsetType) y,
+ stereo_image->rows);
+ if (proceed == MagickFalse)
+ status=MagickFalse;
}
}
return(stereo_image);
{
#define SwirlImageTag "Swirl/Image"
+ CacheView
+ *image_view,
+ *swirl_view;
+
Image
*swirl_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickPixelPacket
zero;
scale;
ResampleFilter
- **resample_filter;
+ **restrict resample_filter;
- CacheView
- *image_view,
- *swirl_view;
+ ssize_t
+ y;
/*
Initialize swirl image attributes.
status=MagickTrue;
progress=0;
GetMagickPixelPacket(swirl_image,&zero);
- resample_filter=AcquireResampleFilterThreadSet(image,MagickTrue,exception);
+ resample_filter=AcquireResampleFilterThreadSet(image,
+ UndefinedVirtualPixelMethod,MagickTrue,exception);
image_view=AcquireCacheView(image);
swirl_view=AcquireCacheView(swirl_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickPixelPacket
pixel;
delta;
register IndexPacket
- *__restrict swirl_indexes;
+ *restrict swirl_indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
swirl_indexes=GetCacheViewAuthenticIndexQueue(swirl_view);
delta.y=scale.y*(double) (y-center.y);
pixel=zero;
- id=GetOpenMPThreadId();
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
/*
Determine if the pixel is within an ellipse.
{
#define TintImageTag "Tint/Image"
+ CacheView
+ *image_view,
+ *tint_view;
+
GeometryInfo
geometry_info;
Image
*tint_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
- MagickStatusType
- flags;
+ MagickOffsetType
+ progress;
MagickPixelPacket
color_vector,
pixel;
- CacheView
- *image_view,
- *tint_view;
+ MagickStatusType
+ flags;
+
+ ssize_t
+ y;
/*
Allocate tint image.
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
status=MagickFalse;
continue;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
MagickPixelPacket
pixel;
weight=QuantumScale*p->red-0.5;
pixel.red=(MagickRealType) p->red+color_vector.red*(1.0-(4.0*
(weight*weight)));
- q->red=RoundToQuantum(pixel.red);
+ SetRedPixelComponent(q,ClampRedPixelComponent(&pixel));
weight=QuantumScale*p->green-0.5;
pixel.green=(MagickRealType) p->green+color_vector.green*(1.0-(4.0*
(weight*weight)));
- q->green=RoundToQuantum(pixel.green);
+ SetGreenPixelComponent(q,ClampGreenPixelComponent(&pixel));
weight=QuantumScale*p->blue-0.5;
pixel.blue=(MagickRealType) p->blue+color_vector.blue*(1.0-(4.0*
(weight*weight)));
- q->blue=RoundToQuantum(pixel.blue);
- q->opacity=p->opacity;
+ SetBluePixelComponent(q,ClampBluePixelComponent(&pixel));
+ SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
p++;
q++;
}
% The format of the VignetteImage method is:
%
% Image *VignetteImage(const Image *image,const double radius,
-% const double sigma,const long x,const long y,ExceptionInfo *exception)
+% const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
*/
MagickExport Image *VignetteImage(const Image *image,const double radius,
- const double sigma,const long x,const long y,ExceptionInfo *exception)
+ const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
{
char
ellipse[MaxTextExtent];
(void) QueryColorDatabase("#ffffff",&draw_info->fill,exception);
(void) QueryColorDatabase("#ffffff",&draw_info->stroke,exception);
(void) FormatMagickString(ellipse,MaxTextExtent,
- "ellipse %g,%g,%g,%g,0.0,360.0",image->columns/2.0,image->rows/2.0,
- image->columns/2.0-x,image->rows/2.0-y);
+ "ellipse %g,%g,%g,%g,0.0,360.0",image->columns/2.0,
+ image->rows/2.0,image->columns/2.0-x,image->rows/2.0-y);
draw_info->primitive=AcquireString(ellipse);
(void) DrawImage(oval_image,draw_info);
draw_info=DestroyDrawInfo(draw_info);
{
#define WaveImageTag "Wave/Image"
+ CacheView
+ *wave_view;
+
Image
*wave_image;
- long
- progress,
- y;
-
MagickBooleanType
status;
+ MagickOffsetType
+ progress;
+
MagickPixelPacket
zero;
MagickRealType
*sine_map;
- register long
+ register ssize_t
i;
ResampleFilter
- **resample_filter;
+ **restrict resample_filter;
- CacheView
- *wave_view;
+ ssize_t
+ y;
/*
Initialize wave image attributes.
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- wave_image=CloneImage(image,image->columns,(unsigned long) (image->rows+2.0*
+ wave_image=CloneImage(image,image->columns,(size_t) (image->rows+2.0*
fabs(amplitude)),MagickTrue,exception);
if (wave_image == (Image *) NULL)
return((Image *) NULL);
wave_image=DestroyImage(wave_image);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
}
- for (i=0; i < (long) wave_image->columns; i++)
- sine_map[i]=fabs(amplitude)+amplitude*sin((2*MagickPI*i)/wave_length);
+ for (i=0; i < (ssize_t) wave_image->columns; i++)
+ sine_map[i]=fabs(amplitude)+amplitude*sin((double) ((2.0*MagickPI*i)/
+ wave_length));
/*
Wave image.
*/
status=MagickTrue;
progress=0;
GetMagickPixelPacket(wave_image,&zero);
- resample_filter=AcquireResampleFilterThreadSet(image,MagickTrue,exception);
+ resample_filter=AcquireResampleFilterThreadSet(image,
+ BackgroundVirtualPixelMethod,MagickTrue,exception);
wave_view=AcquireCacheView(wave_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
- for (y=0; y < (long) wave_image->rows; y++)
+ for (y=0; y < (ssize_t) wave_image->rows; y++)
{
+ const int
+ id = GetOpenMPThreadId();
+
MagickPixelPacket
pixel;
register IndexPacket
- *__restrict indexes;
+ *restrict indexes;
- register long
- id,
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
if (status == MagickFalse)
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(wave_view);
pixel=zero;
- id=GetOpenMPThreadId();
- (void) SetResampleFilterVirtualPixelMethod(resample_filter[id],
- BackgroundVirtualPixelMethod);
- for (x=0; x < (long) wave_image->columns; x++)
+ for (x=0; x < (ssize_t) wave_image->columns; x++)
{
(void) ResamplePixelColor(resample_filter[id],(double) x,(double) (y-
sine_map[x]),&pixel);