]> granicus.if.org Git - imagemagick/commitdiff
Changed signature of ConformPixelInfo.
authordirk <dirk@git.imagemagick.org>
Tue, 4 Nov 2014 19:47:44 +0000 (19:47 +0000)
committerdirk <dirk@git.imagemagick.org>
Tue, 4 Nov 2014 19:47:44 +0000 (19:47 +0000)
Added calls to ConformPixelInfo

MagickCore/distort.c
MagickCore/image.c
MagickCore/paint.c
MagickCore/pixel.c
MagickCore/pixel.h
coders/null.c

index 0e13c4b8bb56f66315bf1e2f844722bf6bf8bfb3..d20ec57d74b7f6b78827cbae0af738fdd396dfa5 100644 (file)
@@ -2386,9 +2386,8 @@ MagickExport Image *DistortImage(const Image *image,DistortImageMethod method,
       */
       validity = 1.0;
 
-      invalid=distort_image->matte_color;
-      if (distort_image->colorspace == CMYKColorspace)
-        ConvertRGBToCMYK(&invalid);   /* what about other color spaces? */
+      ConformPixelInfo(distort_image,&distort_image->matte_color,&invalid,
+        exception);
       for (i=0; i < (ssize_t) distort_image->columns; i++)
       {
         /* map pixel coordinate to distortion space coordinate */
index 4c6b2550027464fed1fe217922d8d6b44f7325c1..d38834344325bdc4393d3fed09a7377b12f3c2be 100644 (file)
@@ -2083,15 +2083,7 @@ MagickExport MagickBooleanType SetImageBackgroundColor(Image *image,
   assert(image->signature == MagickSignature);
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
-  if ((IsPixelInfoGray(&image->background_color) == MagickFalse) &&
-      (IsGrayColorspace(image->colorspace) != MagickFalse))
-    (void) TransformImageColorspace(image,sRGBColorspace,exception);
-  if ((image->background_color.alpha_trait == BlendPixelTrait) &&
-      (image->alpha_trait != BlendPixelTrait))
-    (void) SetImageAlpha(image,OpaqueAlpha,exception);
-  background=image->background_color;
-  if (image->colorspace == CMYKColorspace)
-    ConvertRGBToCMYK(&background);
+  ConformPixelInfo(image,&image->background_color,&background,exception);
   /*
     Set image background color.
   */
index 9ce61d74eeceb5269a740c197f40df24abfafaa5..b87686633f99a4117f5dca58e5770d3cdc86b41c 100644 (file)
@@ -786,13 +786,8 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
-  if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
-      (IsPixelInfoGray(fill) == MagickFalse))
-    (void) SetImageColorspace(image,sRGBColorspace,exception);
-  conform_fill=(*fill);
-  ConformPixelInfo(image,&conform_fill,exception);
-  conform_target=(*target);
-  ConformPixelInfo(image,&conform_target,exception);
+  ConformPixelInfo(image,fill,&conform_fill,exception);
+  ConformPixelInfo(image,target,&conform_target,exception);
   /*
     Make image color opaque.
   */
index a3be57ee735359ca193d40c1905e9af386b45719..b63dc888d9672fd3bdbc3fea0694066f1fbdd4db 100644 (file)
@@ -199,38 +199,45 @@ MagickExport PixelInfo *ClonePixelInfo(const PixelInfo *pixel)
 %
 %  A description of each parameter follows:
 %
-%    o pixel: the pixel info.
-%
 %    o image: the image.
 %
+%    o source: the source pixel info.
+%
+%    o destination: the destination pixel info.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport void ConformPixelInfo(Image *image,PixelInfo *pixel,
-  ExceptionInfo *exception)
+MagickExport void ConformPixelInfo(Image *image,const PixelInfo *source,
+  PixelInfo *destination,ExceptionInfo *exception)
 {
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  assert(pixel != (const PixelInfo *) NULL);
+  assert(destination != (const PixelInfo *) NULL);
 
+  *destination=(*source);
   if (image->colorspace == CMYKColorspace)
     {
-      if (IssRGBCompatibleColorspace(pixel->colorspace))
-        ConvertRGBToCMYK(pixel);
+      if (IssRGBCompatibleColorspace(destination->colorspace))
+        ConvertRGBToCMYK(destination);
     }
   else
-    if (pixel->colorspace == CMYKColorspace)
+    if (destination->colorspace == CMYKColorspace)
       {
         if (IssRGBCompatibleColorspace(image->colorspace))
-          ConvertCMYKToRGB(pixel);
+          ConvertCMYKToRGB(destination);
       }
 #if 0
   if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
-      (IsPixelInfoGray(pixel) == MagickFalse))
+      (IsPixelInfoGray(destination) == MagickFalse))
     /* TODO: Add this method. */
-    SetPixelInfoGray(pixel);
+    SetPixelInfoGray(destination);
+#else
+  if ((IsPixelInfoGray(&image->background_color) == MagickFalse) &&
+      (IsGrayColorspace(image->colorspace) != MagickFalse))
+    (void) TransformImageColorspace(image,sRGBColorspace,exception);
 #endif
-  if ((pixel->alpha_trait == BlendPixelTrait) &&
+  if ((destination->alpha_trait == BlendPixelTrait) &&
       (image->alpha_trait != BlendPixelTrait))
     (void) SetImageAlpha(image,OpaqueAlpha,exception);
 }
index ad8cbbfe712d93125ea048f903d2ffd9021d7c1d..d4271361048769fca0a2453f95f645300a74218d 100644 (file)
@@ -244,7 +244,7 @@ extern MagickExport MagickRealType
   EncodePixelGamma(const MagickRealType) magick_hot_spot;
 
 extern MagickExport void
-  ConformPixelInfo(Image *,PixelInfo *,ExceptionInfo *),
+  ConformPixelInfo(Image *,const PixelInfo *,PixelInfo *,ExceptionInfo *),
   GetPixelInfo(const Image *,PixelInfo *),
   InitializePixelChannelMap(Image *),
   SetPixelChannelMask(Image *,const ChannelType);
index 34ebe4f85ad0c5d0b487a6138f8f36b864cfad38..6859c5e2a636f93df7865a35746ee0b8db8eeb9d 100644 (file)
@@ -126,11 +126,9 @@ static Image *ReadNULLImage(const ImageInfo *image_info,
     image->columns=1;
   if (image->rows == 0)
     image->rows=1;
+  ConformPixelInfo(image,&image->background_color,&background,exception);
   image->alpha_trait=BlendPixelTrait;
-  GetPixelInfo(image,&background);
   background.alpha=(double) TransparentAlpha;
-  if (image->colorspace == CMYKColorspace)
-    ConvertRGBToCMYK(&background);
   for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);