From: Cristy Date: Fri, 3 Feb 2017 13:33:50 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.4-7~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29f8d579962681f8c85a00826f69aa6157e4f704;p=imagemagick ... --- diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 0ddcbfc05..7be7165d5 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -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)); } diff --git a/MagickCore/identify.c b/MagickCore/identify.c index eb6e29e82..0b3df8d86 100644 --- a/MagickCore/identify.c +++ b/MagickCore/identify.c @@ -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]; diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c index 5268e3e77..ef1139825 100644 --- a/MagickCore/pixel.c +++ b/MagickCore/pixel.c @@ -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)); }