}
for (x=0; x < y; x++)
{
- SetPixelRed(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelRed(image,q)*HighlightFactor+(MagickRealType) foreground*
- (QuantumRange-HighlightFactor))),q);
- SetPixelGreen(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelGreen(image,q)*HighlightFactor+(MagickRealType) foreground*
- (QuantumRange-HighlightFactor))),q);
- SetPixelBlue(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelBlue(image,q)*HighlightFactor+(MagickRealType) foreground*
- (QuantumRange-HighlightFactor))),q);
+ register ssize_t
+ i;
+
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if ((traits & UpdatePixelTrait) != 0)
+ q[i]=ClampToQuantum(QuantumScale*((MagickRealType) q[i]*
+ HighlightFactor+(MagickRealType) foreground*(QuantumRange-
+ HighlightFactor)));
+ }
q+=GetPixelChannels(image);
}
for ( ; x < (ssize_t) (image->columns-y); x++)
{
- SetPixelRed(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelRed(image,q)*AccentuateFactor+(MagickRealType) foreground*
- (QuantumRange-AccentuateFactor))),q);
- SetPixelGreen(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelGreen(image,q)*AccentuateFactor+(MagickRealType) foreground*
- (QuantumRange-AccentuateFactor))),q);
- SetPixelBlue(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelBlue(image,q)*AccentuateFactor+(MagickRealType) foreground*
- (QuantumRange-AccentuateFactor))),q);
+ register ssize_t
+ i;
+
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if ((traits & UpdatePixelTrait) != 0)
+ q[i]=ClampToQuantum(QuantumScale*((MagickRealType) q[i]*
+ AccentuateFactor+(MagickRealType) foreground*(QuantumRange-
+ AccentuateFactor)));
+ }
q+=GetPixelChannels(image);
}
for ( ; x < (ssize_t) image->columns; x++)
{
- SetPixelRed(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelRed(image,q)*ShadowFactor+(MagickRealType) background*
- (QuantumRange-ShadowFactor))),q);
- SetPixelGreen(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelGreen(image,q)*ShadowFactor+(MagickRealType) background*
- (QuantumRange-ShadowFactor))),q);
- SetPixelBlue(image,ClampToQuantum(QuantumScale*((MagickRealType)
- GetPixelBlue(image,q)*ShadowFactor+(MagickRealType) background*
- (QuantumRange-ShadowFactor))),q);
+ register ssize_t
+ i;
+
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelTrait
+ traits;
+
+ traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ if ((traits & UpdatePixelTrait) != 0)
+ q[i]=ClampToQuantum(QuantumScale*((MagickRealType) q[i]*
+ AccentuateFactor+(MagickRealType) foreground*(QuantumRange-
+ AccentuateFactor)));
+ q[i]=ClampToQuantum(QuantumScale*((MagickRealType) q[i]*
+ ShadowFactor+(MagickRealType) background*(QuantumRange-
+ ShadowFactor)));
+ }
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
*floodplane_image;
MagickBooleanType
- skip;
+ skip,
+ status;
PixelInfo
fill,
/*
Push initial segment on stack.
*/
+ status=MagickTrue;
x=x_offset;
y=y_offset;
start=0;
register const Quantum
*restrict p;
- register ssize_t
- x;
-
register Quantum
*restrict q;
+ register ssize_t
+ x;
+
/*
Pop segment off stack.
*/
SetPixelInfo(image,p,&pixel);
if (IsFuzzyEquivalencePixelInfo(&pixel,target) == invert)
break;
- SetPixelAlpha(floodplane_image,
- TransparentAlpha,q);
+ SetPixelAlpha(floodplane_image,TransparentAlpha,q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(floodplane_image);
}
- if (SyncCacheViewAuthenticPixels(floodplane_view,exception) == MagickFalse)
+ status=SyncCacheViewAuthenticPixels(floodplane_view,exception);
+ if (status == MagickFalse)
break;
}
PushSegmentStack(y,start,x-1,offset);
register const Quantum
*restrict p;
- register ssize_t
- x;
-
register Quantum
*restrict q;
+ register ssize_t
+ x;
+
/*
Tile fill color onto floodplane.
*/
SetPixelGreen(image,ClampToQuantum(fill.green),q);
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
SetPixelBlue(image,ClampToQuantum(fill.blue),q);
- if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
- (image->colorspace == CMYKColorspace))
+ if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
SetPixelBlack(image,ClampToQuantum(fill.black),q);
if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
SetPixelAlpha(image,ClampToQuantum(fill.alpha),q);
% The format of the OilPaintImage method is:
%
% Image *OilPaintImage(const Image *image,const double radius,
-% ExceptionInfo *exception)
+% const double sigma,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o radius: the radius of the circular neighborhood.
%
+% o sigma: the standard deviation of the Gaussian, in pixels.
+%
% o exception: return any errors or warnings in this structure.
%
*/
number_threads;
number_threads=GetOpenMPMaximumThreads();
- histogram=(size_t **) AcquireQuantumMemory(number_threads,
- sizeof(*histogram));
+ histogram=(size_t **) AcquireQuantumMemory(number_threads,sizeof(*histogram));
if (histogram == (size_t **) NULL)
return((size_t **) NULL);
(void) ResetMagickMemory(histogram,0,number_threads*sizeof(*histogram));
for (i=0; i < (ssize_t) number_threads; i++)
{
- histogram[i]=(size_t *) AcquireQuantumMemory(count,
- sizeof(**histogram));
+ histogram[i]=(size_t *) AcquireQuantumMemory(count,sizeof(**histogram));
if (histogram[i] == (size_t *) NULL)
return(DestroyHistogramThreadSet(histogram));
}
}
MagickExport Image *OilPaintImage(const Image *image,const double radius,
- ExceptionInfo *exception)
+ const double sigma,ExceptionInfo *exception)
{
#define NumberPaintBins 256
#define OilPaintImageTag "OilPaint/Image"
progress;
size_t
- **restrict histograms,
+ **histograms,
width;
ssize_t
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- width=GetOptimalKernelWidth2D(radius,0.5);
+ width=GetOptimalKernelWidth2D(radius,sigma);
paint_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
if (paint_image == (Image *) NULL)
return((Image *) NULL);
register const Quantum
*restrict p;
- register ssize_t
- x;
-
register Quantum
*restrict q;
register size_t
*histogram;
+ register ssize_t
+ x;
+
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t)
{
for (u=0; u < (ssize_t) width; u++)
{
- k=(ssize_t) ScaleQuantumToChar(GetPixelIntensity(image,p+u+i));
+ k=(ssize_t) ScaleQuantumToChar(GetPixelIntensity(image,p+
+ GetPixelChannels(image)*(u+i)));
histogram[k]++;
if (histogram[k] > count)
{
}
i+=(ssize_t) (image->columns+width);
}
- SetPixelRed(paint_image,GetPixelRed(image,p+j*
- GetPixelChannels(image)),q);
- SetPixelGreen(paint_image,GetPixelGreen(image,p+j*
- GetPixelChannels(image)),q);
- SetPixelBlue(paint_image,GetPixelBlue(image,p+j*
- GetPixelChannels(image)),q);
- if (image->colorspace == CMYKColorspace)
+ if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
+ SetPixelRed(paint_image,GetPixelRed(image,p+j*
+ GetPixelChannels(image)),q);
+ if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
+ SetPixelGreen(paint_image,GetPixelGreen(image,p+j*
+ GetPixelChannels(image)),q);
+ if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
+ SetPixelBlue(paint_image,GetPixelBlue(image,p+j*
+ GetPixelChannels(image)),q);
+ if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
SetPixelBlack(paint_image,GetPixelBlack(image,p+j*
GetPixelChannels(image)),q);
- if (image->matte != MagickFalse)
+ if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
SetPixelAlpha(paint_image,GetPixelAlpha(image,p+j*
GetPixelChannels(image)),q);
p+=GetPixelChannels(image);
% OpaquePaintImage() changes any pixel that matches color with the color
% defined by fill.
%
-% By default color must match a particular pixel color exactly. However,
-% in many cases two colors may differ by a small amount. Fuzz defines
-% how much tolerance is acceptable to consider two colors as the same.
-% For example, set fuzz to 10 and the color red at intensities of 100 and
-% 102 respectively are now interpreted as the same color.
+% By default color must match a particular pixel color exactly. However, in
+% many cases two colors may differ by a small amount. Fuzz defines how much
+% tolerance is acceptable to consider two colors as the same. For example,
+% set fuzz to 10 and the color red at intensities of 100 and 102 respectively
+% are now interpreted as the same color.
%
% The format of the OpaquePaintImage method is:
%
PixelInfo
pixel;
- register ssize_t
- x;
-
register Quantum
*restrict q;
+ register ssize_t
+ x;
+
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
SetPixelGreen(image,ClampToQuantum(fill->green),q);
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
SetPixelBlue(image,ClampToQuantum(fill->blue),q);
- if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
- (image->colorspace == CMYKColorspace))
+ if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
SetPixelBlack(image,ClampToQuantum(fill->black),q);
if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
SetPixelAlpha(image,ClampToQuantum(fill->alpha),q);
% TransparentPaintImage() changes the opacity value associated with any pixel
% that matches color to the value defined by opacity.
%
-% By default color must match a particular pixel color exactly. However,
-% in many cases two colors may differ by a small amount. Fuzz defines
-% how much tolerance is acceptable to consider two colors as the same.
-% For example, set fuzz to 10 and the color red at intensities of 100 and
-% 102 respectively are now interpreted as the same color.
+% By default color must match a particular pixel color exactly. However, in
+% many cases two colors may differ by a small amount. Fuzz defines how much
+% tolerance is acceptable to consider two colors as the same. For example,
+% set fuzz to 10 and the color red at intensities of 100 and 102 respectively
+% are now interpreted as the same color.
%
% The format of the TransparentPaintImage method is:
%
%
*/
MagickExport MagickBooleanType TransparentPaintImage(Image *image,
- const PixelInfo *target,const Quantum opacity,
- const MagickBooleanType invert,ExceptionInfo *exception)
+ const PixelInfo *target,const Quantum opacity,const MagickBooleanType invert,
+ ExceptionInfo *exception)
{
#define TransparentPaintImageTag "Transparent/Image"
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
% TransparentPaintImageChroma() changes the opacity value associated with any
% pixel that matches color to the value defined by opacity.
%
-% As there is one fuzz value for the all the channels, the
-% TransparentPaintImage() API is not suitable for the operations like chroma,
-% where the tolerance for similarity of two color component (RGB) can be
-% different, Thus we define this method take two target pixels (one
-% low and one hight) and all the pixels of an image which are lying between
-% these two pixels are made transparent.
+% As there is one fuzz value for the all the channels, TransparentPaintImage()
+% is not suitable for the operations like chroma, where the tolerance for
+% similarity of two color component (RGB) can be different. Thus we define
+% this method to take two target pixels (one low and one high) and all the
+% pixels of an image which are lying between these two pixels are made
+% transparent.
%
-% The format of the TransparentPaintImage method is:
+% The format of the TransparentPaintImageChroma method is:
%
-% MagickBooleanType TransparentPaintImage(Image *image,
-% const PixelInfo *low,const PixelInfo *hight,
-% const Quantum opacity,const MagickBooleanType invert,
-% ExceptionInfo *exception)
+% MagickBooleanType TransparentPaintImageChroma(Image *image,
+% const PixelInfo *low,const PixelInfo *high,const Quantum opacity,
+% const MagickBooleanType invert,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
PixelInfo
pixel;
- register ssize_t
- x;
-
register Quantum
*restrict q;
+ register ssize_t
+ x;
+
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
SetPixelInfo(image,q,&pixel);
match=((pixel.red >= low->red) && (pixel.red <= high->red) &&
(pixel.green >= low->green) && (pixel.green <= high->green) &&
- (pixel.blue >= low->blue) && (pixel.blue <= high->blue)) ?
- MagickTrue : MagickFalse;
+ (pixel.blue >= low->blue) && (pixel.blue <= high->blue)) ? MagickTrue :
+ MagickFalse;
if (match != invert)
SetPixelAlpha(image,opacity,q);
q+=GetPixelChannels(image);