% MagickCore Image Special Effects Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1996 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 "MagickCore/attribute.h"
#include "MagickCore/cache.h"
#include "MagickCore/cache-view.h"
+#include "MagickCore/channel.h"
#include "MagickCore/color.h"
#include "MagickCore/color-private.h"
#include "MagickCore/colorspace-private.h"
/*
Define declarations.
*/
-#define LeftShiftOperator 0xf5
-#define RightShiftOperator 0xf6
-#define LessThanEqualOperator 0xf7
-#define GreaterThanEqualOperator 0xf8
-#define EqualOperator 0xf9
-#define NotEqualOperator 0xfa
-#define LogicalAndOperator 0xfb
-#define LogicalOrOperator 0xfc
-#define ExponentialNotation 0xfd
-
+#define LeftShiftOperator 0xf5U
+#define RightShiftOperator 0xf6U
+#define LessThanEqualOperator 0xf7U
+#define GreaterThanEqualOperator 0xf8U
+#define EqualOperator 0xf9U
+#define NotEqualOperator 0xfaU
+#define LogicalAndOperator 0xfbU
+#define LogicalOrOperator 0xfcU
+#define ExponentialNotation 0xfdU
+
struct _FxInfo
{
const Image
fx_info->exception=AcquireExceptionInfo();
fx_info->images=image;
fx_info->colors=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
- RelinquishMagickMemory);
+ RelinquishAlignedMemory);
fx_info->symbols=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
RelinquishMagickMemory);
fx_info->view=(CacheView **) AcquireQuantumMemory(GetImageListLength(
(void) SubstituteString(&fx_info->expression,"E-1.0*","E-");
(void) SubstituteString(&fx_info->expression,"e-1.0*","e-");
/*
- Convert complex to simple operators.
+ Convert compound to simple operators.
*/
fx_op[1]='\0';
*fx_op=(char) LeftShiftOperator;
noise_image=DestroyImage(noise_image);
return((Image *) NULL);
}
- if (IsGrayColorspace(image->colorspace) != MagickFalse)
- (void) TransformImageColorspace(noise_image,RGBColorspace,exception);
/*
Add noise in each row.
*/
(noise_traits == UndefinedPixelTrait))
continue;
if (((noise_traits & CopyPixelTrait) != 0) ||
- (GetPixelMask(image,p) != 0))
+ (GetPixelReadMask(image,p) == 0))
{
SetPixelChannel(noise_image,channel,p[i],q);
continue;
clone_image=CloneImage(image,0,0,MagickTrue,exception);
if (clone_image == (Image *) NULL)
return((Image *) NULL);
- (void) SetImageType(clone_image,GrayscaleType,exception);
- edge_image=EdgeImage(clone_image,radius,sigma,exception);
+ edge_image=EdgeImage(clone_image,radius,exception);
clone_image=DestroyImage(clone_image);
if (edge_image == (Image *) NULL)
return((Image *) NULL);
return((Image *) NULL);
(void) NormalizeImage(charcoal_image,exception);
(void) NegateImage(charcoal_image,MagickFalse,exception);
- (void) SetImageType(charcoal_image,GrayscaleType,exception);
+ (void) GrayscaleImage(charcoal_image,image->intensity,exception);
return(charcoal_image);
}
\f
colorize_image=DestroyImage(colorize_image);
return((Image *) NULL);
}
- if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
+ if ((IsGrayColorspace(image->colorspace) != MagickFalse) ||
(IsPixelInfoGray(colorize) != MagickFalse))
- (void) SetImageColorspace(colorize_image,RGBColorspace,exception);
+ (void) SetImageColorspace(colorize_image,sRGBColorspace,exception);
if ((colorize_image->alpha_trait != BlendPixelTrait) &&
(colorize->alpha_trait == BlendPixelTrait))
(void) SetImageAlpha(colorize_image,OpaqueAlpha,exception);
(colorize_traits == UndefinedPixelTrait))
continue;
if (((colorize_traits & CopyPixelTrait) != 0) ||
- (GetPixelMask(image,p) != 0))
+ (GetPixelReadMask(image,p) == 0))
{
SetPixelChannel(colorize_image,channel,p[i],q);
continue;
level=0;
point.x=(double) x;
point.y=(double) y;
- if (isalpha((int) *(p+1)) == 0)
+ if (isalpha((int) ((unsigned char) *(p+1))) == 0)
{
if (strchr("suv",(int) *p) != (char *) NULL)
{
if (*p == '.')
p++;
}
- if ((isalpha((int) *(p+1)) == 0) && (*p == 'p'))
+ if ((*p == 'p') && (isalpha((int) ((unsigned char) *(p+1))) == 0))
{
p++;
if (*p == '{')
(void) InterpolatePixelInfo(image,fx_info->view[i],image->interpolate,
point.x,point.y,&pixel,exception);
if ((strlen(p) > 2) && (LocaleCompare(p,"intensity") != 0) &&
- (LocaleCompare(p,"luminance") != 0) && (LocaleCompare(p,"hue") != 0) &&
- (LocaleCompare(p,"saturation") != 0) &&
+ (LocaleCompare(p,"luma") != 0) && (LocaleCompare(p,"luminance") != 0) &&
+ (LocaleCompare(p,"hue") != 0) && (LocaleCompare(p,"saturation") != 0) &&
(LocaleCompare(p,"lightness") != 0))
{
char
default:
return(0.0);
}
- return(0.0);
}
if (LocaleCompare(symbol,"c") == 0)
return(QuantumScale*pixel.red);
&lightness);
return(lightness);
}
+ if (LocaleCompare(symbol,"luma") == 0)
+ {
+ double
+ luma;
+
+ luma=0.212656*pixel.red+0.715158*pixel.green+0.072186*pixel.blue;
+ return(QuantumScale*luma);
+ }
if (LocaleCompare(symbol,"luminance") == 0)
{
double
luminence;
- luminence=0.21267f*pixel.red+0.71516f*pixel.green+0.07217f*pixel.blue;
+ luminence=0.212656*pixel.red+0.715158*pixel.green+0.072186*pixel.blue;
return(QuantumScale*luminence);
}
break;
while (*expression != '\0')
{
precedence=UndefinedPrecedence;
- if ((isspace((int) ((char) *expression)) != 0) || (c == (int) '@'))
+ if ((isspace((int) ((unsigned char) *expression)) != 0) || (c == (int) '@'))
{
expression++;
continue;
}
default:
{
- if (((c != 0) && ((isdigit((int) ((char) c)) != 0) ||
- (strchr(")",c) != (char *) NULL))) &&
- (((islower((int) ((char) *expression)) != 0) ||
- (strchr("(",(int) *expression) != (char *) NULL)) ||
- ((isdigit((int) ((char) c)) == 0) &&
- (isdigit((int) ((char) *expression)) != 0))) &&
- (strchr("xy",(int) *expression) == (char *) NULL))
+ if (((c != 0) && ((isdigit((int) ((unsigned char) c)) != 0) ||
+ (strchr(")",(int) ((unsigned char) c)) != (char *) NULL))) &&
+ (((islower((int) ((unsigned char) *expression)) != 0) ||
+ (strchr("(",(int) ((unsigned char) *expression)) != (char *) NULL)) ||
+ ((isdigit((int) ((unsigned char) c)) == 0) &&
+ (isdigit((int) ((unsigned char) *expression)) != 0))) &&
+ (strchr("xy",(int) ((unsigned char) *expression)) == (char *) NULL))
precedence=MultiplyPrecedence;
break;
}
*beta=0.0;
if (exception->severity != UndefinedException)
return(0.0);
- while (isspace((int) *expression) != 0)
+ while (isspace((int) ((unsigned char) *expression)) != 0)
expression++;
if (*expression == '\0')
{
if (*expression != '@')
fx_expression=ConstantString(expression);
else
- fx_expression=FileToString(expression+1,~0,exception);
+ fx_expression=FileToString(expression+1,~0UL,exception);
for (i=0; i < (ssize_t) number_threads; i++)
{
MagickBooleanType
(fx_traits == UndefinedPixelTrait))
continue;
if (((fx_traits & CopyPixelTrait) != 0) ||
- (GetPixelMask(image,p) != 0))
+ (GetPixelReadMask(image,p) == 0))
{
SetPixelChannel(fx_image,channel,p[i],q);
continue;
CacheView
*image_view,
- *implode_view;
+ *implode_view,
+ *interpolate_view;
Image
*implode_image;
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
+ interpolate_view=AcquireVirtualCacheView(image,exception);
implode_view=AcquireAuthenticCacheView(implode_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status) \
if (status == MagickFalse)
continue;
- p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(implode_view,0,y,implode_image->columns,1,
exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
/*
Determine if the pixel is within an ellipse.
*/
- if (GetPixelMask(image,p) != 0)
+ if (GetPixelReadMask(image,p) == 0)
{
+ SetPixelBackgoundColor(implode_image,q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(implode_image);
continue;
if (distance > 0.0)
factor=pow(sin((double) (MagickPI*sqrt((double) distance)/radius/
2)),-amount);
- status=InterpolatePixelChannels(image,image_view,implode_image,method,
- (double) (factor*delta.x/scale.x+center.x),(double) (factor*delta.y/
- scale.y+center.y),q,exception);
+ status=InterpolatePixelChannels(image,interpolate_view,implode_image,
+ method,(double) (factor*delta.x/scale.x+center.x),(double) (factor*
+ delta.y/scale.y+center.y),q,exception);
}
p+=GetPixelChannels(image);
q+=GetPixelChannels(implode_image);
}
}
implode_view=DestroyCacheView(implode_view);
+ interpolate_view=DestroyCacheView(interpolate_view);
image_view=DestroyCacheView(image_view);
if (status == MagickFalse)
implode_image=DestroyImage(implode_image);
for (i=0; i < (ssize_t) GetPixelChannels(morph_image); i++)
{
- PixelChannel channel=GetPixelChannelChannel(image,i);
- PixelTrait traits=GetPixelChannelTraits(image,channel);
- PixelTrait morph_traits=GetPixelChannelTraits(morph_image,channel);
+ PixelChannel channel=GetPixelChannelChannel(morph_image,i);
+ PixelTrait traits=GetPixelChannelTraits(morph_image,channel);
+ PixelTrait morph_traits=GetPixelChannelTraits(morph_images,channel);
if ((traits == UndefinedPixelTrait) ||
(morph_traits == UndefinedPixelTrait))
continue;
if (((morph_traits & CopyPixelTrait) != 0) ||
- (GetPixelMask(image,p) != 0))
+ (GetPixelReadMask(morph_images,p) == 0))
{
SetPixelChannel(morph_image,channel,p[i],q);
continue;
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+ q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
}
(void) SyncCacheViewAuthenticPixels(image_view,exception);
if (segment->x1 != segment->x2)
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+ q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
}
(void) SyncCacheViewAuthenticPixels(image_view,exception);
}
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+ q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
}
(void) SyncCacheViewAuthenticPixels(image_view,exception);
}
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+ q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
}
(void) SyncCacheViewAuthenticPixels(image_view,exception);
}
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+ q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
}
(void) SyncCacheViewAuthenticPixels(image_view,exception);
}
DrawInfo
*annotate_info;
+ ImageInfo
+ *image_info;
+
MagickBooleanType
status;
caption_image=CloneImage(image,image->columns,1,MagickTrue,exception);
if (caption_image == (Image *) NULL)
return((Image *) NULL);
+ image_info=AcquireImageInfo();
annotate_info=CloneDrawInfo((const ImageInfo *) NULL,draw_info);
- text=InterpretImageProperties((ImageInfo *) NULL,(Image *) image,caption,
+ text=InterpretImageProperties(image_info,(Image *) image,caption,
exception);
+ image_info=DestroyImageInfo(image_info);
(void) CloneString(&annotate_info->text,text);
count=FormatMagickCaption(caption_image,annotate_info,MagickTrue,&metrics,
&text,exception);
SetPixelGreen(sepia_image,ClampToQuantum(tone),q);
if ((double) GetPixelBlue(image,q) < tone)
SetPixelBlue(sepia_image,ClampToQuantum(tone),q);
+ SetPixelAlpha(sepia_image,GetPixelAlpha(image,p),q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(sepia_image);
}
if (clone_image == (Image *) NULL)
return((Image *) NULL);
if (IsGrayColorspace(image->colorspace) != MagickFalse)
- (void) TransformImageColorspace(clone_image,RGBColorspace,exception);
+ (void) SetImageColorspace(clone_image,sRGBColorspace,exception);
(void) SetImageVirtualPixelMethod(clone_image,TransparentVirtualPixelMethod,
exception);
border_info.width=(size_t) floor(2.0*sigma+0.5);
register ssize_t
i;
- if (GetPixelMask(random_image,q) != 0)
+ if (GetPixelReadMask(random_image,q) == 0)
{
q+=GetPixelChannels(random_image);
continue;
random_image=DestroyImage(random_image);
if (blur_image == (Image *) NULL)
return((Image *) NULL);
- dodge_image=EdgeImage(blur_image,radius,1.0,exception);
+ dodge_image=EdgeImage(blur_image,radius,exception);
blur_image=DestroyImage(blur_image);
if (dodge_image == (Image *) NULL)
return((Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ if (IsGrayColorspace(image->colorspace) != MagickFalse)
+ (void) SetImageColorspace(image,sRGBColorspace,exception);
if (image->storage_class == PseudoClass)
{
register ssize_t
if ((double) image->colormap[i].red > threshold)
image->colormap[i].red=QuantumRange-image->colormap[i].red;
if ((double) image->colormap[i].green > threshold)
- image->colormap[i].green=QuantumRange-
- image->colormap[i].green;
+ image->colormap[i].green=QuantumRange-image->colormap[i].green;
if ((double) image->colormap[i].blue > threshold)
- image->colormap[i].blue=QuantumRange-
- image->colormap[i].blue;
+ image->colormap[i].blue=QuantumRange-image->colormap[i].blue;
}
}
/*
register ssize_t
i;
- if (GetPixelMask(image,q) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
q+=GetPixelChannels(image);
continue;
CacheView
*image_view,
+ *interpolate_view,
*swirl_view;
Image
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
+ interpolate_view=AcquireVirtualCacheView(image,exception);
swirl_view=AcquireAuthenticCacheView(swirl_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(progress,status) \
if (status == MagickFalse)
continue;
- p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+ p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(swirl_view,0,y,swirl_image->columns,1,
exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
/*
Determine if the pixel is within an ellipse.
*/
- if (GetPixelMask(image,p) != 0)
+ if (GetPixelReadMask(image,p) == 0)
{
+ SetPixelBackgoundColor(swirl_image,q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(swirl_image);
continue;
factor=1.0-sqrt((double) distance)/radius;
sine=sin((double) (degrees*factor*factor));
cosine=cos((double) (degrees*factor*factor));
- status=InterpolatePixelChannels(image,image_view,swirl_image,method,
- ((cosine*delta.x-sine*delta.y)/scale.x+center.x),(double)
+ status=InterpolatePixelChannels(image,interpolate_view,swirl_image,
+ method,((cosine*delta.x-sine*delta.y)/scale.x+center.x),(double)
((sine*delta.x+cosine*delta.y)/scale.y+center.y),q,exception);
}
p+=GetPixelChannels(image);
}
}
swirl_view=DestroyCacheView(swirl_view);
+ interpolate_view=DestroyCacheView(interpolate_view);
image_view=DestroyCacheView(image_view);
if (status == MagickFalse)
swirl_image=DestroyImage(swirl_image);
*image_view,
*tint_view;
+ double
+ intensity;
+
GeometryInfo
geometry_info;
MagickOffsetType
progress;
- double
- intensity;
-
PixelInfo
color_vector;
}
if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
(IsPixelInfoGray(tint) == MagickFalse))
- (void) SetImageColorspace(tint_image,RGBColorspace,exception);
+ (void) SetImageColorspace(tint_image,sRGBColorspace,exception);
if (blend == (const char *) NULL)
return(tint_image);
/*
color_vector.red=geometry_info.rho;
color_vector.green=geometry_info.rho;
color_vector.blue=geometry_info.rho;
- color_vector.alpha=OpaqueAlpha;
+ color_vector.alpha=(MagickRealType) OpaqueAlpha;
if ((flags & SigmaValue) != 0)
color_vector.green=geometry_info.sigma;
if ((flags & XiValue) != 0)
color_vector.alpha=geometry_info.chi;
}
intensity=(double) GetPixelInfoIntensity(tint);
- color_vector.red=(double) (color_vector.red*tint->red/100.0-
- intensity);
- color_vector.green=(double) (color_vector.green*tint->green/100.0-
- intensity);
- color_vector.blue=(double) (color_vector.blue*tint->blue/100.0-
- intensity);
- color_vector.black=(double) (color_vector.black*tint->black/100.0-
- intensity);
- color_vector.alpha=(double) (color_vector.alpha*tint->alpha/100.0-
- intensity);
+ color_vector.red=(double) (color_vector.red*tint->red/100.0-intensity);
+ color_vector.green=(double) (color_vector.green*tint->green/100.0-intensity);
+ color_vector.blue=(double) (color_vector.blue*tint->blue/100.0-intensity);
+ color_vector.black=(double) (color_vector.black*tint->black/100.0-intensity);
+ color_vector.alpha=(double) (color_vector.alpha*tint->alpha/100.0-intensity);
/*
Tint image.
*/
(tint_traits == UndefinedPixelTrait))
continue;
if (((tint_traits & CopyPixelTrait) != 0) ||
- (GetPixelMask(image,p) != 0))
+ (GetPixelReadMask(image,p) == 0))
{
SetPixelChannel(tint_image,channel,p[i],q);
continue;