]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 4 Nov 2014 00:03:27 +0000 (00:03 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 4 Nov 2014 00:03:27 +0000 (00:03 +0000)
MagickCore/colorspace-private.h
MagickCore/colorspace.c
MagickCore/paint.c
MagickCore/pixel.c
MagickCore/pixel.h

index 53bc6a6800b80d26565e29004ec96938d1ccc8f5..20bb0a5c84616681bf64d93016dbc9994cf3137e 100644 (file)
 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
@@ -37,7 +47,7 @@ static inline void ConvertRGBToCMYK(PixelInfo *pixel)
     magenta,
     red,
     yellow;
-                                                                                
+
   if (pixel->colorspace != sRGBColorspace)
     {
       red=QuantumScale*pixel->red;
index 3eb3941cda7a447d5cecd16a94fdfc5c17e188e1..f7e9e9e67dbc23139b25767d0040bf2e7f29ba14 100644 (file)
@@ -1259,16 +1259,6 @@ static inline ssize_t RoundToYCC(const double value)
   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)
 {
index 7b7e024e208be443024f315e61867d773ce02ab5..9ce61d74eeceb5269a740c197f40df24abfafaa5 100644 (file)
@@ -728,7 +728,7 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  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
@@ -738,9 +738,9 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
 %
 %  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:
 %
@@ -771,6 +771,8 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
     progress;
 
   PixelInfo
+    conform_fill,
+    conform_target,
     zero;
 
   ssize_t
@@ -787,9 +789,10 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
   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.
   */
@@ -824,8 +827,8 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
     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)
index a2a652f5025cf08813c81d9816814ef13be69a93..a3be57ee735359ca193d40c1905e9af386b45719 100644 (file)
@@ -44,6 +44,7 @@
 #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"
@@ -158,11 +159,11 @@ MagickExport PixelChannelMap *ClonePixelChannelMap(PixelChannelMap *channel_map)
 %
 %  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)
@@ -182,6 +183,63 @@ 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                                           %
 %                                                                             %
 %                                                                             %
@@ -4419,7 +4477,6 @@ MagickExport MagickBooleanType InterpolatePixelChannel(const Image *image,
     x_offset,
     y_offset;
 
-  assert(image != (Image *) NULL);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(image_view != (CacheView *) NULL);
@@ -4841,7 +4898,6 @@ MagickExport MagickBooleanType InterpolatePixelChannels(const Image *source,
   PixelInterpolateMethod
     interpolate;
 
-  assert(source != (Image *) NULL);
   assert(source != (Image *) NULL);
   assert(source->signature == MagickSignature);
   assert(source_view != (CacheView *) NULL);
index 44499483804405f747a342a7b9899b85e675199e..ad8cbbfe712d93125ea048f903d2ffd9021d7c1d 100644 (file)
@@ -244,8 +244,9 @@ extern MagickExport MagickRealType
   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)