]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Fri, 3 Feb 2017 13:33:50 +0000 (08:33 -0500)
committerCristy <urban-warrior@imagemagick.org>
Fri, 3 Feb 2017 13:34:27 +0000 (08:34 -0500)
MagickCore/channel.c
MagickCore/identify.c
MagickCore/pixel.c

index 0ddcbfc058158cce2ed53d859d446d7f4853fe82..7be7165d54518fc597b6f24f40585d3d298d8894 100644 (file)
@@ -239,14 +239,11 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
     return((Image *) NULL);
   if (expression == (const char *) NULL)
     return(destination_image);
-  if (image->colorspace == UndefinedColorspace)
+  status=SetImageStorageClass(destination_image,DirectClass,exception);
+  if (status == MagickFalse)
     {
-      status=SetImageStorageClass(destination_image,DirectClass,exception);
-      if (status == MagickFalse)
-        {
-          destination_image=DestroyImageList(destination_image);
-          return(destination_image);
-        }
+      destination_image=GetLastImageInList(destination_image);
+      return((Image *) NULL);
     }
   destination_channel=RedPixelChannel;
   channel_mask=UndefinedChannel;
@@ -286,12 +283,6 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
         (void) SetPixelChannelMask(destination_image,channel_mask);
         if ((channel_op == ExtractChannelOp) && (channels == 1))
           (void) SetImageColorspace(destination_image,GRAYColorspace,exception);
-        status=SetImageStorageClass(destination_image,DirectClass,exception);
-        if (status == MagickFalse)
-          {
-            destination_image=DestroyImageList(destination_image);
-            return(destination_image);
-          }
         canvas=CloneImage(source_image,0,0,MagickTrue,exception);
         if (canvas == (Image *) NULL)
           {
@@ -357,7 +348,7 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
               }
           }
         destination_channel=(PixelChannel) i;
-        if (image->colorspace == UndefinedColorspace)
+        if (i >= GetPixelChannels(destination_image))
           (void) SetPixelMetaChannels(destination_image,(size_t) (
             destination_channel-GetPixelChannels(destination_image)+1),
             exception);
@@ -385,14 +376,8 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
             destination_image->write_mask=MagickTrue;
             break;
           }
-          case MetaPixelChannel:
           default:
-          {
-            (void) SetPixelMetaChannels(destination_image,(size_t) (
-              destination_channel-GetPixelChannels(destination_image)+1),
-              exception);
             break;
-          }
         }
         channel_mask=(ChannelType) (channel_mask | ParseChannelOption(token));
         if (((channels >= 1)  || (destination_channel >= 1)) &&
@@ -442,12 +427,6 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
   (void) SetPixelChannelMask(destination_image,channel_mask);
   if ((channel_op == ExtractChannelOp) && (channels == 1))
     (void) SetImageColorspace(destination_image,GRAYColorspace,exception);
-  status=SetImageStorageClass(destination_image,DirectClass,exception);
-  if (status == MagickFalse)
-    {
-      destination_image=GetLastImageInList(destination_image);
-      return((Image *) NULL);
-    }
   return(GetFirstImageInList(destination_image));
 }
 
index eb6e29e820909e9b0bfae2a1558a738773ad039b..0b3df8d860aeaa6fe136ac2a8d06aaf9ea2fbe70 100644 (file)
@@ -556,7 +556,6 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
       switch (colorspace)
       {
         case RGBColorspace:
-        default:
         {
           (void) PrintChannelLocations(file,image,RedPixelChannel,"Red",
             statistic_type,max_locations,channel_statistics);
@@ -584,6 +583,13 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
             statistic_type,max_locations,channel_statistics);
           break;
         }
+        default:
+        {
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+            (void) PrintChannelLocations(file,image,(PixelChannel) i,"Gray",
+              statistic_type,max_locations,channel_statistics);
+          break;
+        }
       }
       if (image->alpha_trait != UndefinedPixelTrait)
         (void) PrintChannelLocations(file,image,AlphaPixelChannel,"Alpha",
@@ -797,11 +803,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         }
         default:
         {
-          ssize_t
-            number_channels;
-
-          number_channels=image->number_channels+image->number_meta_channels;
-          for (i=0; i < (ssize_t) number_channels; i++)
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
             (void) FormatLocaleFile(file,"    Channel %.20g: %.20g-bit\n",
               (double) i,(double) channel_statistics[i].depth);
           break;
@@ -853,11 +855,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         }
         default:
         {
-          ssize_t
-            number_channels;
-
-          number_channels=image->number_channels+image->number_meta_channels;
-          for (i=0; i < (ssize_t) number_channels; i++)
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             char
               channel[MagickPathExtent];
@@ -919,11 +917,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         }
         default:
         {
-          ssize_t
-            number_channels;
-
-          number_channels=image->number_channels+image->number_meta_channels;
-          for (i=0; i < (ssize_t) number_channels; i++)
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             char
               channel[MagickPathExtent];
@@ -991,11 +985,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
         }
         default:
         {
-          ssize_t
-            number_channels;
-
-          number_channels=image->number_channels+image->number_meta_channels;
-          for (i=0; i < (ssize_t) number_channels; i++)
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             char
               channel[MagickPathExtent];
index 5268e3e77b18b851ae7ebbf940833124c40b511f..ef113982562fde63471966792f7c7f6889924c73 100644 (file)
@@ -4425,25 +4425,10 @@ MagickExport void InitializePixelChannelMap(Image *image)
   assert(image->signature == MagickCoreSignature);
   (void) ResetMagickMemory(image->channel_map,0,MaxPixelChannels*
     sizeof(*image->channel_map));
-  n=0;
-  if (image->colorspace == UndefinedColorspace)
-    {
-      /*
-        Multispectral image.
-      */
-      for (i=0; i < (ssize_t) image->number_channels; i++)
-        SetPixelChannelAttributes(image,(PixelChannel) i,UpdatePixelTrait,n++);
-      for (i=0; i < (ssize_t) image->number_meta_channels; i++)
-        SetPixelChannelAttributes(image,(PixelChannel) (image->number_channels+
-          i),UpdatePixelTrait,n++);
-      if (image->debug != MagickFalse)
-        LogPixelChannels(image);
-      SetImageChannelMask(image,image->channel_mask);
-      return;
-    }
   trait=UpdatePixelTrait;
   if (image->alpha_trait != UndefinedPixelTrait)
     trait=(PixelTrait) (trait | BlendPixelTrait);
+  n=0;
   if (image->colorspace == GRAYColorspace)
     {
       SetPixelChannelAttributes(image,BluePixelChannel,trait,n);
@@ -4467,10 +4452,10 @@ MagickExport void InitializePixelChannelMap(Image *image)
   if (image->write_mask != MagickFalse)
     SetPixelChannelAttributes(image,WriteMaskPixelChannel,CopyPixelTrait,n++);
   assert((n+image->number_meta_channels) < MaxPixelChannels);
-  image->number_channels=(size_t) n;
   for (i=0; i < (ssize_t) image->number_meta_channels; i++)
     SetPixelChannelAttributes(image,(PixelChannel) (MetaPixelChannel+i),
-      CopyPixelTrait,n++);
+      UpdatePixelTrait,n++);
+  image->number_channels=(size_t) n;
   if (image->debug != MagickFalse)
     LogPixelChannels(image);
   SetImageChannelMask(image,image->channel_mask);
@@ -6352,5 +6337,6 @@ MagickExport MagickBooleanType SetPixelMetaChannels(Image *image,
   const size_t number_meta_channels,ExceptionInfo *exception)
 {
   image->number_meta_channels=number_meta_channels;
+  InitializePixelChannelMap(image);
   return(SyncImagePixelCache(image,exception));
 }