From: cristy Date: Wed, 13 Mar 2013 12:03:11 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cf5d375fa7abe962164b39a35948fe76b4d239a;p=imagemagick --- diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c index f7e551016..6ab5204be 100644 --- a/MagickCore/annotate.c +++ b/MagickCore/annotate.c @@ -290,8 +290,6 @@ MagickExport MagickBooleanType AnnotateImage(Image *image, } if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(image,RGBColorspace,exception); status=MagickTrue; for (i=0; textlist[i] != (char *) NULL; i++) { diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 2ce31b11b..dd55b72cc 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -4829,9 +4829,6 @@ MagickPrivate VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image, if ((image->background_color.alpha_trait == BlendPixelTrait) && (image->alpha_trait != BlendPixelTrait)) (void) SetCacheAlphaChannel(image,OpaqueAlpha,exception); - if ((IsPixelInfoGray(&image->background_color) == MagickFalse) && - (IsGrayColorspace(image->colorspace) != MagickFalse)) - (void) TransformImageColorspace(image,RGBColorspace,exception); break; } case TransparentVirtualPixelMethod: diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 80c253643..f8c58eb36 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -239,8 +239,6 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression, destination_image=CloneImage(source_image,0,0,MagickTrue,exception); if (destination_image == (Image *) NULL) return((Image *) NULL); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace((Image *) image,RGBColorspace,exception); if (expression == (const char *) NULL) return(destination_image); destination_channel=RedPixelChannel; @@ -290,8 +288,6 @@ MagickExport Image *ChannelFxImage(const Image *image,const char *expression, destination_image=DestroyImageList(destination_image); return(destination_image); } - if (IsGrayColorspace(canvas->colorspace) != MagickFalse) - (void) TransformImageColorspace(canvas,RGBColorspace,exception); AppendImageToList(&destination_image,canvas); destination_image=GetLastImageInList(destination_image); GetMagickToken(p,&p,token); @@ -488,8 +484,6 @@ MagickExport Image *CombineImages(const Image *image, combine_image=DestroyImage(combine_image); return((Image *) NULL); } - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) SetImageColorspace(combine_image,RGBColorspace,exception); if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) combine_image->alpha_trait=BlendPixelTrait; /* diff --git a/MagickCore/composite.c b/MagickCore/composite.c index 6aa8439d5..7183a0f69 100644 --- a/MagickCore/composite.c +++ b/MagickCore/composite.c @@ -580,8 +580,6 @@ MagickExport MagickBooleanType CompositeImage(Image *image, composite_image=CloneImage(composite,0,0,MagickTrue,exception); if (composite_image == (const Image *) NULL) return(MagickFalse); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) SetImageColorspace(image,RGBColorspace,exception); (void) SetImageColorspace(composite_image,image->colorspace,exception); if ((image->alpha_trait == BlendPixelTrait) && (composite_image->alpha_trait != BlendPixelTrait)) diff --git a/MagickCore/decorate.c b/MagickCore/decorate.c index 454582a4b..3bc9d8294 100644 --- a/MagickCore/decorate.c +++ b/MagickCore/decorate.c @@ -230,9 +230,6 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info, frame_image=DestroyImage(frame_image); return((Image *) NULL); } - if ((IsPixelInfoGray(&frame_image->matte_color) == MagickFalse) && - (IsGrayColorspace(frame_image->colorspace) != MagickFalse)) - (void) SetImageColorspace(frame_image,RGBColorspace,exception); if ((frame_image->matte_color.alpha_trait == BlendPixelTrait) && (frame_image->alpha_trait != BlendPixelTrait)) (void) SetImageAlpha(frame_image,OpaqueAlpha,exception); diff --git a/MagickCore/distort.c b/MagickCore/distort.c index 53227acdc..58f7a2248 100644 --- a/MagickCore/distort.c +++ b/MagickCore/distort.c @@ -2290,9 +2290,6 @@ MagickExport Image *DistortImage(const Image *image,DistortImageMethod method, distort_image=DestroyImage(distort_image); return((Image *) NULL); } - if ((IsPixelInfoGray(&distort_image->background_color) == MagickFalse) && - (IsGrayColorspace(distort_image->colorspace) != MagickFalse)) - (void) TransformImageColorspace(distort_image,RGBColorspace,exception); if (distort_image->background_color.alpha_trait == BlendPixelTrait) distort_image->alpha_trait=BlendPixelTrait; distort_image->page.x=geometry.x; diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 0a7a29920..0a9f976a3 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -4145,10 +4145,6 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, draw_info->affine.rx,draw_info->affine.ry,draw_info->affine.sy, draw_info->affine.tx,draw_info->affine.ty); } - if ((IsGrayColorspace(image->colorspace) != MagickFalse) && - ((IsPixelInfoGray(&draw_info->fill) == MagickFalse) || - (IsPixelInfoGray(&draw_info->stroke) == MagickFalse))) - (void) SetImageColorspace(image,RGBColorspace,exception); status=MagickTrue; x=(ssize_t) ceil(primitive_info->point.x-0.5); y=(ssize_t) ceil(primitive_info->point.y-0.5); diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 7c8919ebb..262c66bd5 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -324,8 +324,6 @@ MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image, assert(clut_image->signature == MagickSignature); if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(image,RGBColorspace,exception); clut_map=(PixelInfo *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*clut_map)); if (clut_map == (PixelInfo *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", @@ -1954,8 +1952,6 @@ MagickExport MagickBooleanType HaldClutImage(Image *image, assert(hald_image->signature == MagickSignature); if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(image,RGBColorspace,exception); if (image->alpha_trait != BlendPixelTrait) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); /* @@ -2308,8 +2304,6 @@ MagickExport MagickBooleanType LevelizeImage(Image *image, assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) SetImageColorspace(image,RGBColorspace,exception); if (image->storage_class == PseudoClass) for (i=0; i < (ssize_t) image->colors; i++) { diff --git a/MagickCore/fx.c b/MagickCore/fx.c index befa72077..eca389a17 100644 --- a/MagickCore/fx.c +++ b/MagickCore/fx.c @@ -306,8 +306,6 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type, noise_image=DestroyImage(noise_image); return((Image *) NULL); } - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(noise_image,RGBColorspace,exception); /* Add noise in each row. */ @@ -700,9 +698,6 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend, colorize_image=DestroyImage(colorize_image); return((Image *) NULL); } - if ((IsGrayColorspace(image->colorspace) != MagickFalse) && - (IsPixelInfoGray(colorize) != MagickFalse)) - (void) SetImageColorspace(colorize_image,RGBColorspace,exception); if ((colorize_image->alpha_trait != BlendPixelTrait) && (colorize->alpha_trait == BlendPixelTrait)) (void) SetImageAlpha(colorize_image,OpaqueAlpha,exception); @@ -4265,8 +4260,6 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha, clone_image=CloneImage(image,0,0,MagickTrue,exception); if (clone_image == (Image *) NULL) return((Image *) NULL); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(clone_image,RGBColorspace,exception); (void) SetImageVirtualPixelMethod(clone_image,TransparentVirtualPixelMethod, exception); border_info.width=(size_t) floor(2.0*sigma+0.5); @@ -5244,9 +5237,6 @@ MagickExport Image *TintImage(const Image *image,const char *blend, tint_image=DestroyImage(tint_image); return((Image *) NULL); } - if ((IsGrayColorspace(image->colorspace) != MagickFalse) && - (IsPixelInfoGray(tint) == MagickFalse)) - (void) SetImageColorspace(tint_image,RGBColorspace,exception); if (blend == (const char *) NULL) return(tint_image); /* diff --git a/MagickCore/image.c b/MagickCore/image.c index 14c875cb8..e5cbb0805 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -2363,9 +2363,6 @@ 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,RGBColorspace,exception); if ((image->background_color.alpha_trait == BlendPixelTrait) && (image->alpha_trait != BlendPixelTrait)) (void) SetImageAlpha(image,OpaqueAlpha,exception); diff --git a/MagickCore/option.c b/MagickCore/option.c index 0e4e8c32e..7342697b3 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -1435,7 +1435,9 @@ static const OptionInfo { "Brightness", BrightnessPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, { "Lightness", LightnessPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, { "Rec601Luma", Rec601LumaPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, + { "Rec601Luminance", Rec601LuminanceaPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, { "Rec709Luma", Rec709LumaPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, + { "Rec709Luminance", Rec709LuminanceaPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, { "RMS", RMSPixelIntensityMethod, UndefinedOptionFlag, MagickTrue }, { (char *) NULL, UndefinedPixelIntensityMethod, UndefinedOptionFlag, MagickFalse } }, diff --git a/MagickCore/paint.c b/MagickCore/paint.c index c0821819b..d22a7402e 100644 --- a/MagickCore/paint.c +++ b/MagickCore/paint.c @@ -172,8 +172,6 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image, return(MagickFalse); if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); - if (IsGrayColorspace(image->colorspace) != MagickFalse) - (void) TransformImageColorspace(image,RGBColorspace,exception); if ((image->alpha_trait != BlendPixelTrait) && (draw_info->fill.alpha_trait == BlendPixelTrait)) (void) SetImageAlpha(image,OpaqueAlpha,exception); @@ -780,9 +778,6 @@ 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) TransformImageColorspace(image,RGBColorspace,exception); if ((fill->alpha_trait == BlendPixelTrait) && (image->alpha_trait != BlendPixelTrait)) (void) SetImageAlpha(image,OpaqueAlpha,exception); diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c index 7e20f1f46..4ea2321bb 100644 --- a/MagickCore/pixel.c +++ b/MagickCore/pixel.c @@ -2098,16 +2098,19 @@ MagickExport void GetPixelInfo(const Image *image,PixelInfo *pixel) % GetPixelIntensity() returns a single sample intensity value from the red, % green, and blue components of a pixel based on the selected method: % -% Rec601Luma 0.298839R + 0.586811G + 0.114350B -% Rec709Luma 0.21260R + 0.71520G + 0.07220B -% Brightness max(R, G, B) -% Lightness (min(R, G, B) + max(R, G, B)) / 2.0 -% RMS (R^2 + G^2 + B^2) / 3.0 -% Average (R + G + B) / 3.0 +% Rec601Luma 0.298839R' + 0.586811G' + 0.114350B' +% Rec601Luminance 0.298839R + 0.586811G + 0.114350B +% Rec709Luma 0.21260R' + 0.71520G' + 0.07220B' +% Rec709Luminance 0.21260R + 0.71520G + 0.07220B +% Brightness max(R, G, B) +% Lightness (min(R, G, B) + max(R, G, B)) / 2.0 +% RMS (R'^2 + G'^2 + B'^2) / 3.0 +% Average (R' + G' + B') / 3.0 % % The format of the GetPixelIntensity method is: % -% GetPixelIntensity(const Image *image,const Quantum *pixel) +% MagickRealType GetPixelIntensity(const Image *image, +% const Quantum *pixel) % % A description of each parameter follows: % @@ -2151,6 +2154,11 @@ MagickExport MagickRealType GetPixelIntensity(const Image *restrict image, { case Rec601LumaPixelIntensityMethod: default: + { + intensity=0.298839f*red+0.586811f*green+0.114350f*blue; + break; + } + case Rec601LuminancePixelIntensityMethod: { if (image->colorspace == sRGBColorspace) { @@ -2162,6 +2170,11 @@ MagickExport MagickRealType GetPixelIntensity(const Image *restrict image, break; } case Rec709LumaPixelIntensityMethod: + { + intensity=0.21260f*red+0.71520f*green+0.07220f*blue; + break; + } + case Rec709LuminancePixelIntensityMethod: { if (image->colorspace == sRGBColorspace) { @@ -2174,23 +2187,11 @@ MagickExport MagickRealType GetPixelIntensity(const Image *restrict image, } case BrightnessPixelIntensityMethod: { - if (image->colorspace == sRGBColorspace) - { - red=DecodePixelGamma(red); - green=DecodePixelGamma(green); - blue=DecodePixelGamma(blue); - } intensity=MagickMax(MagickMax(red,green),blue); break; } case LightnessPixelIntensityMethod: { - if (image->colorspace == sRGBColorspace) - { - red=DecodePixelGamma(red); - green=DecodePixelGamma(green); - blue=DecodePixelGamma(blue); - } intensity=MagickMin(MagickMin(red,green),blue); break; } diff --git a/MagickCore/pixel.h b/MagickCore/pixel.h index 474ed59ee..f9f0b1f51 100644 --- a/MagickCore/pixel.h +++ b/MagickCore/pixel.h @@ -91,7 +91,9 @@ typedef enum BrightnessPixelIntensityMethod, LightnessPixelIntensityMethod, Rec601LumaPixelIntensityMethod, + Rec601LuminancePixelIntensityMethod, Rec709LumaPixelIntensityMethod, + Rec709LuminancePixelIntensityMethod, RMSPixelIntensityMethod } PixelIntensityMethod;