extern "C" {
#endif
+static inline void ConvertCMYKToRGB(PixelInfo *pixel)
+{
+ pixel->red=((QuantumRange-(QuantumScale*pixel->red*(QuantumRange-
+ pixel->black)+pixel->black)));
+ pixel->green=((QuantumRange-(QuantumScale*pixel->green*(QuantumRange-
+ pixel->black)+pixel->black)));
+ pixel->blue=((QuantumRange-(QuantumScale*pixel->blue*(QuantumRange-
+ pixel->black)+pixel->black)));
+}
+
static inline void ConvertRGBToCMYK(PixelInfo *pixel)
{
MagickRealType
magenta,
red,
yellow;
-
+
if (pixel->colorspace != sRGBColorspace)
{
red=QuantumScale*pixel->red;
return((ssize_t) (value+0.5));
}
-static inline void ConvertCMYKToRGB(PixelInfo *pixel)
-{
- pixel->red=((QuantumRange-(QuantumScale*pixel->red*
- (QuantumRange-pixel->black)+pixel->black)));
- pixel->green=((QuantumRange-(QuantumScale*pixel->green*
- (QuantumRange-pixel->black)+pixel->black)));
- pixel->blue=((QuantumRange-(QuantumScale*pixel->blue*
- (QuantumRange-pixel->black)+pixel->black)));
-}
-
static inline void ConvertLabToRGB(const double L,const double a,
const double b,double *red,double *green,double *blue)
{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% OpaquePaintImage() changes any pixel that matches color with the color
-% defined by fill.
+% defined by fill argument.
%
% 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
%
% The format of the OpaquePaintImage method is:
%
-% MagickBooleanType OpaquePaintImage(Image *image,
-% const PixelInfo *target,const PixelInfo *fill,
-% const MagickBooleanType invert,ExceptionInfo *exception)
+% MagickBooleanType OpaquePaintImage(Image *image,const PixelInfo *target,
+% const PixelInfo *fill,const MagickBooleanType invert,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
progress;
PixelInfo
+ conform_fill,
+ conform_target,
zero;
ssize_t
if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
(IsPixelInfoGray(fill) == MagickFalse))
(void) SetImageColorspace(image,sRGBColorspace,exception);
- if ((fill->alpha_trait == BlendPixelTrait) &&
- (image->alpha_trait != BlendPixelTrait))
- (void) SetImageAlpha(image,OpaqueAlpha,exception);
+ conform_fill=(*fill);
+ ConformPixelInfo(image,&conform_fill,exception);
+ conform_target=(*target);
+ ConformPixelInfo(image,&conform_target,exception);
/*
Make image color opaque.
*/
for (x=0; x < (ssize_t) image->columns; x++)
{
GetPixelInfoPixel(image,q,&pixel);
- if (IsFuzzyEquivalencePixelInfo(&pixel,target) != invert)
- SetPixelInfoPixel(image,fill,q);
+ if (IsFuzzyEquivalencePixelInfo(&pixel,&conform_target) != invert)
+ SetPixelInfoPixel(image,&conform_fill,q);
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
#include "MagickCore/blob-private.h"
#include "MagickCore/cache-private.h"
#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/draw.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
%
% The format of the ClonePixelInfo method is:
%
-% PixelInfo *ClonePixelInfo(const PixelInfo *pixel_info)
+% PixelInfo *ClonePixelInfo(const PixelInfo *pixel)
%
% A description of each parameter follows:
%
-% o pixel_info: the pixel info.
+% o pixel: the pixel info.
%
*/
MagickExport PixelInfo *ClonePixelInfo(const PixelInfo *pixel)
% %
% %
% %
++ C o n f o r m P i x e l I n f o %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ConformPixelInfo() ensures the pixel conforms with the colorspace and alpha
+% attribute of the image.
+%
+% The format of the ConformPixelInfo method is:
+%
+% void *ConformPixelInfo((Image *image,PixelInfo *pixel,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o pixel: the pixel info.
+%
+% o image: the image.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport void ConformPixelInfo(Image *image,PixelInfo *pixel,
+ ExceptionInfo *exception)
+{
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
+ assert(pixel != (const PixelInfo *) NULL);
+
+ if (image->colorspace == CMYKColorspace)
+ {
+ if (IssRGBCompatibleColorspace(pixel->colorspace))
+ ConvertRGBToCMYK(pixel);
+ }
+ else
+ if (pixel->colorspace == CMYKColorspace)
+ {
+ if (IssRGBCompatibleColorspace(image->colorspace))
+ ConvertCMYKToRGB(pixel);
+ }
+#if 0
+ if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
+ (IsPixelInfoGray(pixel) == MagickFalse))
+ /* TODO: Add this method. */
+ SetPixelInfoGray(pixel);
+#endif
+ if ((pixel->alpha_trait == BlendPixelTrait) &&
+ (image->alpha_trait != BlendPixelTrait))
+ (void) SetImageAlpha(image,OpaqueAlpha,exception);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% D e c o d e P i x e l G a m m a %
% %
% %
x_offset,
y_offset;
- assert(image != (Image *) NULL);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
assert(image_view != (CacheView *) NULL);
PixelInterpolateMethod
interpolate;
- assert(source != (Image *) NULL);
assert(source != (Image *) NULL);
assert(source->signature == MagickSignature);
assert(source_view != (CacheView *) NULL);
EncodePixelGamma(const MagickRealType) magick_hot_spot;
extern MagickExport void
- InitializePixelChannelMap(Image *),
+ ConformPixelInfo(Image *,PixelInfo *,ExceptionInfo *),
GetPixelInfo(const Image *,PixelInfo *),
+ InitializePixelChannelMap(Image *),
SetPixelChannelMask(Image *,const ChannelType);
#if defined(__cplusplus) || defined(c_plusplus)