% specified, the color value is changed for any neighbor pixel that does not
% match the bordercolor member of image.
%
-% By default target must match a particular pixel color exactly.
-% However, in many cases two colors may differ by a small amount. The
-% fuzz member of image 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 for the purposes of the floodfill.
+% By default target must match a particular pixel color exactly. However,
+% in many cases two colors may differ by a small amount. The fuzz member of
+% image 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 for the
+% purposes of the floodfill.
%
% The format of the FloodfillPaintImage method is:
%
% MagickBooleanType FloodfillPaintImage(Image *image,
% const DrawInfo *draw_info,const PixelInfo target,
% const ssize_t x_offset,const ssize_t y_offset,
-% const MagickBooleanType invert)
+% const MagickBooleanType invert,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o invert: paint any pixel that does not match the target color.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
const DrawInfo *draw_info,const PixelInfo *target,const ssize_t x_offset,
- const ssize_t y_offset,const MagickBooleanType invert)
+ const ssize_t y_offset,const MagickBooleanType invert,
+ ExceptionInfo *exception)
{
#define MaxStacksize (1UL << 15)
#define PushSegmentStack(up,left,right,delta) \
*floodplane_view,
*image_view;
- ExceptionInfo
- *exception;
-
Image
*floodplane_image;
MagickBooleanType
- skip;
+ skip,
+ status;
PixelInfo
fill,
return(MagickFalse);
if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
return(MagickFalse);
- exception=(&image->exception);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if (image->matte == MagickFalse)
- (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
+ (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
/*
Set floodfill state.
*/
floodplane_image=CloneImage(image,0,0,MagickTrue,&image->exception);
if (floodplane_image == (Image *) NULL)
return(MagickFalse);
- (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
+ (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel,exception);
segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
sizeof(*segment_stack));
if (segment_stack == (SegmentInfo *) NULL)
/*
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.
*/
exception);
q=GetCacheViewAuthenticPixels(floodplane_view,x,y,
image->columns-x,1,exception);
- if ((p == (const Quantum *) NULL) ||
- (q == (Quantum *) NULL))
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
for ( ; x < (ssize_t) image->columns; x++)
{
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);
exception);
q=GetCacheViewAuthenticPixels(floodplane_view,x,y,(size_t) (x2-x+1),1,
exception);
- if ((p == (const Quantum *) NULL) ||
- (q == (Quantum *) NULL))
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
for ( ; x <= x2; x++)
{
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);
%
% MagickBooleanType GradientImage(Image *image,const GradientType type,
% const SpreadMethod method,const PixelPacket *start_color,
-% const PixelPacket *stop_color)
+% const PixelPacket *stop_color,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o stop_color: the stop color.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static inline double MagickMax(const double x,const double y)
MagickExport MagickBooleanType GradientImage(Image *image,
const GradientType type,const SpreadMethod method,
- const PixelPacket *start_color,const PixelPacket *stop_color)
+ const PixelPacket *start_color,const PixelPacket *stop_color,
+ ExceptionInfo *exception)
{
DrawInfo
*draw_info;
% 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:
%
% MagickBooleanType OpaquePaintImage(Image *image,
% const PixelPacket *target,const PixelPacket *fill,
-% const MagickBooleanType invert)
+% const MagickBooleanType invert,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o invert: paint any pixel that does not match the target color.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType OpaquePaintImage(Image *image,
- const PixelInfo *target,const PixelInfo *fill,const MagickBooleanType invert)
+ const PixelInfo *target,const PixelInfo *fill,const MagickBooleanType invert,
+ ExceptionInfo *exception)
{
#define OpaquePaintImageTag "Opaque/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
assert(fill != (PixelInfo *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- exception=(&image->exception);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
/*
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:
%
% MagickBooleanType TransparentPaintImage(Image *image,
% const PixelInfo *target,const Quantum opacity,
-% const MagickBooleanType invert)
+% const MagickBooleanType invert,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o invert: paint any pixel that does not match the target color.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType TransparentPaintImage(Image *image,
- const PixelInfo *target,const Quantum opacity,
- const MagickBooleanType invert)
+ const PixelInfo *target,const Quantum opacity,const MagickBooleanType invert,
+ ExceptionInfo *exception)
{
#define TransparentPaintImageTag "Transparent/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
assert(target != (PixelInfo *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- exception=(&image->exception);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if (image->matte == MagickFalse)
- (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
+ (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
/*
Make image color transparent.
*/
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)
+% MagickBooleanType TransparentPaintImageChroma(Image *image,
+% const PixelInfo *low,const PixelInfo *high,const Quantum opacity,
+% const MagickBooleanType invert,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o invert: paint any pixel that does not match the target color.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType TransparentPaintImageChroma(Image *image,
- const PixelInfo *low,const PixelInfo *high,
- const Quantum opacity,const MagickBooleanType invert)
+ const PixelInfo *low,const PixelInfo *high,const Quantum opacity,
+ const MagickBooleanType invert,ExceptionInfo *exception)
{
#define TransparentPaintImageTag "Transparent/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
MagickBooleanType
status;
assert(low != (PixelInfo *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- exception=(&image->exception);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if (image->matte == MagickFalse)
- (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
+ (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
/*
Make image color transparent.
*/
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);