From: cristy Date: Sun, 21 Aug 2011 00:04:26 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~7170 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd5a96cd2b69f218f85a7adc306296a736f91a56;p=imagemagick --- diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index 5b2634276..82ab3d518 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -342,12 +342,12 @@ void Magick::Image::addNoiseChannel( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_); MagickCore::Image* newImage = AddNoiseImage ( image(), noiseType_, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -492,10 +492,10 @@ void Magick::Image::blurChannel( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); MagickCore::Image* newImage = BlurImage( image(), radius_, sigma_, &exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -519,9 +519,9 @@ void Magick::Image::border( const Geometry &geometry_ ) void Magick::Image::channel ( const ChannelType channel_ ) { modifyImage(); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); SeparateImage ( image() ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); throwImageException(); } @@ -1137,10 +1137,10 @@ void Magick::Image::fx ( const std::string expression, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel ); MagickCore::Image* newImage = FxImage ( image(), expression.c_str(), &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -1194,10 +1194,10 @@ void Magick::Image::gaussianBlurChannel ( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); MagickCore::Image* newImage = GaussianBlurImage( image(), width_, sigma_, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -1304,10 +1304,10 @@ void Magick::Image::matteFloodfill ( const Color &target_ , target.green=static_cast(target_).green; target.blue=static_cast(target_).blue; target.alpha=alpha_; - PushPixelChannelMap( image(), AlphaChannel ); + ChannelType channel_mask = SetPixelChannelMask( image(), AlphaChannel ); FloodfillPaintImage ( image(), options()->drawInfo(), &target, x_, y_, method_ == FloodfillMethod ? MagickFalse : MagickTrue); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); throwImageException(); } @@ -1515,9 +1515,9 @@ void Magick::Image::quantumOperator ( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); EvaluateImage( image(), operator_, rvalue_, &exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); } @@ -1538,9 +1538,9 @@ void Magick::Image::quantumOperator ( const ssize_t x_,const ssize_t y_, geometry.y = y_; MagickCore::Image *crop_image = CropImage( image(), &geometry, &exceptionInfo ); - PushPixelChannelMap( image(), channel_); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_); EvaluateImage( crop_image, operator_, rvalue_, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); (void) CompositeImage( image(), image()->matte != MagickFalse ? OverCompositeOp : CopyCompositeOp, crop_image, geometry.x, geometry.y ); crop_image = DestroyImageList(crop_image); @@ -1580,11 +1580,11 @@ void Magick::Image::randomThresholdChannel( const Geometry &thresholds_, ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); modifyImage(); - PushPixelChannelMap( image(), channel_); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_); (void) RandomThresholdImage( image(), static_cast(thresholds_).c_str(), &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); throwImageException(); (void) DestroyExceptionInfo( &exceptionInfo ); } @@ -1897,13 +1897,13 @@ void Magick::Image::sharpenChannel ( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); MagickCore::Image* newImage = SharpenImage( image(), radius_, sigma_, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -1968,10 +1968,10 @@ void Magick::Image::sparseColor ( const ChannelType channel, ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel ); MagickCore::Image* newImage = SparseColorImage ( image(), method, number_arguments, arguments, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -2161,7 +2161,7 @@ void Magick::Image::unsharpmaskChannel ( const ChannelType channel_, { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), channel_ ); + ChannelType channel_mask = SetPixelChannelMask( image(), channel_ ); MagickCore::Image* newImage = UnsharpMaskImage( image(), radius_, @@ -2169,7 +2169,7 @@ void Magick::Image::unsharpmaskChannel ( const ChannelType channel_, amount_, threshold_, &exceptionInfo ); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -3601,7 +3601,7 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); - PushPixelChannelMap( image(), RedChannel); + ChannelType channel_mask = SetPixelChannelMask( image(), RedChannel); (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo); statistics->red.minimum=minimum; statistics->red.maximum=maximum; @@ -3609,9 +3609,9 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) &statistics->red.standard_deviation,&exceptionInfo); (void) GetImageKurtosis( image(),&statistics->red.kurtosis, &statistics->red.skewness,&exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); - PushPixelChannelMap( image(), GreenChannel); + channel_mask = SetPixelChannelMask( image(), GreenChannel); (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo); statistics->green.minimum=minimum; statistics->green.maximum=maximum; @@ -3619,9 +3619,9 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) &statistics->green.standard_deviation,&exceptionInfo); (void) GetImageKurtosis( image(),&statistics->green.kurtosis, &statistics->green.skewness,&exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); - PushPixelChannelMap( image(), GreenChannel); + channel_mask = SetPixelChannelMask( image(), GreenChannel); (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo); statistics->blue.minimum=minimum; statistics->blue.maximum=maximum; @@ -3629,9 +3629,9 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) &statistics->blue.standard_deviation,&exceptionInfo); (void) GetImageKurtosis( image(),&statistics->blue.kurtosis, &statistics->blue.skewness,&exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); - PushPixelChannelMap( image(), AlphaChannel); + channel_mask = SetPixelChannelMask( image(), AlphaChannel); (void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo); statistics->alpha.minimum=minimum; statistics->alpha.maximum=maximum; @@ -3639,7 +3639,7 @@ void Magick::Image::statistics ( ImageStatistics *statistics ) &statistics->alpha.standard_deviation,&exceptionInfo); (void) GetImageKurtosis( image(),&statistics->alpha.kurtosis, &statistics->alpha.skewness,&exceptionInfo); - PopPixelChannelMap( image() ); + (void) SetPixelChannelMap( image(), channel_mask ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); diff --git a/Magick++/lib/Magick++/Include.h b/Magick++/lib/Magick++/Include.h index f5dc84c6e..85ce2114d 100644 --- a/Magick++/lib/Magick++/Include.h +++ b/Magick++/lib/Magick++/Include.h @@ -810,11 +810,9 @@ namespace Magick using MagickCore::PixelWand; using MagickCore::PointInfo; using MagickCore::PopDrawingWand; - using MagickCore::PopPixelChannelMap; using MagickCore::ProfileImage; using MagickCore::ProfileInfo; using MagickCore::PushDrawingWand; - using MagickCore::PushPixelChannelMap; using MagickCore::QuantizeImage; using MagickCore::QuantizeInfo; using MagickCore::QuantumInfo; @@ -863,8 +861,9 @@ namespace Magick using MagickCore::SetLogEventMask; using MagickCore::SetMagickInfo; using MagickCore::SetMagickResourceLimit; - using MagickCore::SetStringInfoDatum; using MagickCore::SetImageVirtualPixelMethod; + using MagickCore::SetPixelChannelMask; + using MagickCore::SetStringInfoDatum; using MagickCore::ShadeImage; using MagickCore::SharpenImage; using MagickCore::SharpenImage; diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c index 6452e8982..4fe8beaf1 100644 --- a/MagickCore/annotate.c +++ b/MagickCore/annotate.c @@ -1434,13 +1434,15 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, origin.x+=direction*face->glyph->advance.x; metrics->origin.x=origin.x; metrics->origin.y=origin.y; - FT_Done_Glyph(last_glyph.image); + if (last_glyph.id != 0) + FT_Done_Glyph(last_glyph.image); last_glyph=glyph; code=GetUTFCode(p); } if (utf8 != (unsigned char *) NULL) utf8=(unsigned char *) RelinquishMagickMemory(utf8); - FT_Done_Glyph(last_glyph.image); + if (last_glyph.id != 0) + FT_Done_Glyph(last_glyph.image); if ((draw_info->stroke.alpha != TransparentAlpha) || (draw_info->stroke_pattern != (Image *) NULL)) { diff --git a/MagickCore/attribute.c b/MagickCore/attribute.c index 2dc14da07..c53016ede 100644 --- a/MagickCore/attribute.c +++ b/MagickCore/attribute.c @@ -605,7 +605,8 @@ MagickExport MagickBooleanType IsImageGray(const Image *image, type=UndefinedType; break; } - if ((type == BilevelType) && (IsPixelMonochrome(image,p) == MagickFalse)) + if ((type == BilevelType) && + (IsPixelMonochrome(image,p) == MagickFalse)) type=GrayscaleType; p+=GetPixelChannels(image); } diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 1f40a0331..ac76101ea 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -3997,7 +3997,6 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if ((image->columns == 0) || (image->rows == 0)) ThrowBinaryException(CacheError,"NoPixelsDefinedInCache",image->filename); - StandardPixelChannelMap(image); cache_info=(CacheInfo *) image->cache; assert(cache_info->signature == MagickSignature); source_info=(*cache_info); @@ -4009,6 +4008,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, cache_info->matte=image->matte; cache_info->rows=image->rows; cache_info->columns=image->columns; + InitializePixelChannelMap(image); cache_info->number_channels=GetPixelChannels(image); cache_info->metacontent_extent=image->metacontent_extent; cache_info->mode=mode; diff --git a/MagickCore/display.c b/MagickCore/display.c index ece4c11cc..77da91668 100644 --- a/MagickCore/display.c +++ b/MagickCore/display.c @@ -10054,6 +10054,9 @@ static MagickBooleanType XMatteEditImage(Display *display, case FloodfillMethod: case FillToBorderMethod: { + ChannelType + channel_mask; + DrawInfo *draw_info; @@ -10078,11 +10081,11 @@ static MagickBooleanType XMatteEditImage(Display *display, (DrawInfo *) NULL); draw_info->fill.alpha=ClampToQuantum(InterpretLocaleValue(matte, (char **) NULL)); - PushPixelChannelMap(*image,AlphaChannel); + channel_mask=SetPixelChannelMask(*image,AlphaChannel); (void) FloodfillPaintImage(*image,draw_info,&target,(ssize_t) x_offset,(ssize_t) y_offset,method == FloodfillMethod ? MagickFalse : MagickTrue); - PopPixelChannelMap(*image); + (void) SetPixelChannelMap(*image,channel_mask); draw_info=DestroyDrawInfo(draw_info); break; } diff --git a/MagickCore/distort.c b/MagickCore/distort.c index 816d9e852..5465cb621 100644 --- a/MagickCore/distort.c +++ b/MagickCore/distort.c @@ -1459,18 +1459,22 @@ MagickExport Image *DistortResizeImage(const Image *image, } else { + ChannelType + channel_mask; + + Image + *resize_alpha; + /* Image has transparency so handle colors and alpha separatly. Basically we need to separate Virtual-Pixel alpha in the resized image, so only the actual original images alpha channel is used. - */ - Image - *resize_alpha; - /* distort alpha channel separately */ - PushPixelChannelMap(tmp_image,AlphaChannel); + distort alpha channel separately + */ + channel_mask=SetPixelChannelMask(tmp_image,AlphaChannel); (void) SeparateImage(tmp_image); - PopPixelChannelMap(tmp_image); + SetPixelChannelMap(tmp_image,channel_mask); (void) SetImageAlphaChannel(tmp_image,OpaqueAlphaChannel,exception); resize_alpha=DistortImage(tmp_image,AffineDistortion,12,distort_args, MagickTrue,exception), diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 366c2a3b9..0e21687d1 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -4349,6 +4349,9 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, case FloodfillMethod: case FillToBorderMethod: { + ChannelType + channel_mask; + PixelInfo target; @@ -4359,11 +4362,11 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image, target.green=(MagickRealType) draw_info->border_color.green; target.blue=(MagickRealType) draw_info->border_color.blue; } - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); (void) FloodfillPaintImage(image,draw_info,&target,x,y, primitive_info->method == FloodfillMethod ? MagickFalse : MagickTrue); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case ResetMethod: diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 5a052063f..ff1457460 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -129,17 +129,20 @@ MagickExport MagickBooleanType AutoGammaImage(Image *image, status=MagickTrue; for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { + ChannelType + channel_mask; + PixelTrait traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); if ((traits & UpdatePixelTrait) == 0) continue; - PushPixelChannelMap(image,(ChannelType) i); + channel_mask=SetPixelChannelMask(image,(ChannelType) i); status=GetImageMean(image,&mean,&sans,exception); gamma=log(mean*QuantumScale)/log_mean; status&=LevelImage(image,0.0,(double) QuantumRange,gamma,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); if (status == MagickFalse) break; } @@ -2561,6 +2564,9 @@ MagickExport MagickBooleanType LevelImageColors(Image *image, const PixelInfo *black_color,const PixelInfo *white_color, const MagickBooleanType invert) { + ChannelType + channel_mask; + MagickStatusType status; @@ -2576,78 +2582,78 @@ MagickExport MagickBooleanType LevelImageColors(Image *image, { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,RedChannel); + channel_mask=SetPixelChannelMask(image,RedChannel); status|=LevelImage(image,black_color->red,white_color->red,1.0, &image->exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,GreenChannel); + channel_mask=SetPixelChannelMask(image,GreenChannel); status|=LevelImage(image,black_color->green,white_color->green,1.0, &image->exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,BlueChannel); + channel_mask=SetPixelChannelMask(image,BlueChannel); status|=LevelImage(image,black_color->blue,white_color->blue,1.0, &image->exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && (image->colorspace == CMYKColorspace)) { - PushPixelChannelMap(image,BlackChannel); + channel_mask=SetPixelChannelMask(image,BlackChannel); status|=LevelImage(image,black_color->black,white_color->black,1.0, &image->exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && (image->matte == MagickTrue)) { - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); status|=LevelImage(image,black_color->alpha,white_color->alpha,1.0, &image->exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } } else { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,RedChannel); + channel_mask=SetPixelChannelMask(image,RedChannel); status|=LevelizeImage(image,black_color->red,white_color->red,1.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,GreenChannel); + channel_mask=SetPixelChannelMask(image,GreenChannel); status|=LevelizeImage(image,black_color->green,white_color->green, 1.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,BlueChannel); + channel_mask=SetPixelChannelMask(image,BlueChannel); status|=LevelizeImage(image,black_color->blue,white_color->blue,1.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && (image->colorspace == CMYKColorspace)) { - PushPixelChannelMap(image,BlackChannel); + channel_mask=SetPixelChannelMask(image,BlackChannel); status|=LevelizeImage(image,black_color->black,white_color->black, 1.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && (image->matte == MagickTrue)) { - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); status|=LevelizeImage(image,black_color->alpha,white_color->alpha, 1.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } } return(status == 0 ? MagickFalse : MagickTrue); diff --git a/MagickCore/fx.c b/MagickCore/fx.c index 7fe94d982..552062efd 100644 --- a/MagickCore/fx.c +++ b/MagickCore/fx.c @@ -4128,6 +4128,9 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity, CacheView *border_view; + ChannelType + channel_mask; + Image *border_image, *clone_image, @@ -4222,9 +4225,9 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity, } } border_view=DestroyCacheView(border_view); - PushPixelChannelMap(border_image,AlphaChannel); + channel_mask=SetPixelChannelMask(border_image,AlphaChannel); shadow_image=BlurImage(border_image,0.0,sigma,exception); - PopPixelChannelMap(border_image); + (void) SetPixelChannelMap(border_image,channel_mask); border_image=DestroyImage(border_image); if (shadow_image == (Image *) NULL) return((Image *) NULL); diff --git a/MagickCore/histogram.c b/MagickCore/histogram.c index a1db3db7a..ac93dc4d5 100644 --- a/MagickCore/histogram.c +++ b/MagickCore/histogram.c @@ -980,6 +980,9 @@ MagickExport MagickBooleanType IsPaletteImage(const Image *image, MagickExport MagickBooleanType MinMaxStretchImage(Image *image, const double black,const double white,ExceptionInfo *exception) { + ChannelType + channel_mask; + double min, max; @@ -1005,55 +1008,55 @@ MagickExport MagickBooleanType MinMaxStretchImage(Image *image, */ if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,RedChannel); + channel_mask=SetPixelChannelMask(image,RedChannel); (void) GetImageRange(image,&min,&max,exception); min+=black; max-=white; if (fabs(min-max) >= MagickEpsilon) status&=LevelImage(image,min,max,1.0,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,GreenChannel); + channel_mask=SetPixelChannelMask(image,GreenChannel); (void) GetImageRange(image,&min,&max,exception); min+=black; max-=white; if (fabs(min-max) >= MagickEpsilon) status&=LevelImage(image,min,max,1.0,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { - PushPixelChannelMap(image,BlueChannel); + channel_mask=SetPixelChannelMask(image,BlueChannel); (void) GetImageRange(image,&min,&max,exception); min+=black; max-=white; if (fabs(min-max) >= MagickEpsilon) status&=LevelImage(image,min,max,1.0,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && (image->colorspace == CMYKColorspace)) { - PushPixelChannelMap(image,BlackChannel); + channel_mask=SetPixelChannelMask(image,BlackChannel); (void) GetImageRange(image,&min,&max,exception); min+=black; max-=white; if (fabs(min-max) >= MagickEpsilon) status&=LevelImage(image,min,max,1.0,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && (image->matte == MagickTrue)) { - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); (void) GetImageRange(image,&min,&max,exception); min+=black; max-=white; if (fabs(min-max) >= MagickEpsilon) status&=LevelImage(image,min,max,1.0,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); } return(status != 0 ? MagickTrue : MagickFalse); } diff --git a/MagickCore/image.c b/MagickCore/image.c index 9f183592d..65ecf6e4a 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -185,6 +185,7 @@ MagickExport Image *AcquireImage(const ImageInfo *image_info) GetTimerInfo(&image->timer); image->ping=MagickFalse; image->cache=AcquirePixelCache(0); + image->channel_mask=DefaultChannels; image->channel_map=AcquirePixelChannelMap(); image->blob=CloneBlobInfo((BlobInfo *) NULL); image->debug=IsEventLogging(); @@ -806,7 +807,7 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns, clone_image->magick_rows=image->magick_rows; clone_image->type=image->type; clone_image->sync=image->sync; - clone_image->map=image->map; + clone_image->mask=image->mask; clone_image->channel_map=ClonePixelChannelMap(image->channel_map); (void) CopyMagickString(clone_image->magick_filename,image->magick_filename, MaxTextExtent); @@ -2428,6 +2429,9 @@ MagickExport MagickBooleanType SeparateImage(Image *image) */ MagickExport Image *SeparateImages(const Image *image,ExceptionInfo *exception) { + ChannelType + channel_mask; + Image *images, *separate_image; @@ -2440,42 +2444,42 @@ MagickExport Image *SeparateImages(const Image *image,ExceptionInfo *exception) if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { separate_image=CloneImage(image,0,0,MagickTrue,exception); - PushPixelChannelMap(separate_image,RedChannel); + channel_mask=SetPixelChannelMask(separate_image,RedChannel); (void) SeparateImage(separate_image); - PopPixelChannelMap(separate_image); + (void) SetPixelChannelMap(separate_image,channel_mask); AppendImageToList(&images,separate_image); } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { separate_image=CloneImage(image,0,0,MagickTrue,exception); - PushPixelChannelMap(separate_image,GreenChannel); + channel_mask=SetPixelChannelMask(separate_image,GreenChannel); (void) SeparateImage(separate_image); - PopPixelChannelMap(separate_image); + (void) SetPixelChannelMap(separate_image,channel_mask); AppendImageToList(&images,separate_image); } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { separate_image=CloneImage(image,0,0,MagickTrue,exception); - PushPixelChannelMap(separate_image,BlueChannel); + channel_mask=SetPixelChannelMask(separate_image,BlueChannel); (void) SeparateImage(separate_image); - PopPixelChannelMap(separate_image); + (void) SetPixelChannelMap(separate_image,channel_mask); AppendImageToList(&images,separate_image); } if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && (image->colorspace == CMYKColorspace)) { separate_image=CloneImage(image,0,0,MagickTrue,exception); - PushPixelChannelMap(separate_image,BlackChannel); + channel_mask=SetPixelChannelMask(separate_image,BlackChannel); (void) SeparateImage(separate_image); - PopPixelChannelMap(separate_image); + (void) SetPixelChannelMap(separate_image,channel_mask); AppendImageToList(&images,separate_image); } if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) { separate_image=CloneImage(image,0,0,MagickTrue,exception); - PushPixelChannelMap(separate_image,AlphaChannel); + channel_mask=SetPixelChannelMask(separate_image,AlphaChannel); (void) SeparateImage(separate_image); - PopPixelChannelMap(separate_image); + (void) SetPixelChannelMap(separate_image,channel_mask); AppendImageToList(&images,separate_image); } return(images); @@ -2515,6 +2519,9 @@ MagickExport Image *SeparateImages(const Image *image,ExceptionInfo *exception) MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelType alpha_type,ExceptionInfo *exception) { + ChannelType + channel_mask; + MagickBooleanType status; @@ -2607,9 +2614,9 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, Special usage case for SeparateImage(): copy grayscale color to the alpha channel. */ - PushPixelChannelMap(image,GrayChannel); + channel_mask=SetPixelChannelMask(image,GrayChannel); status=SeparateImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); image->matte=MagickTrue; /* make sure transparency is now on! */ if (alpha_type == ShapeAlphaChannel) { @@ -2627,9 +2634,9 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, } case ExtractAlphaChannel: { - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); status=SeparateImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); image->matte=MagickFalse; break; } @@ -3606,13 +3613,16 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type) } case PaletteBilevelMatteType: { + ChannelType + channel_mask; + if (IsRGBColorspace(image->colorspace) == MagickFalse) status=TransformImageColorspace(image,RGBColorspace); if (image->matte == MagickFalse) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); (void) BilevelImage(image,(double) QuantumRange/2.0); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); quantize_info=AcquireQuantizeInfo(image_info); status=QuantizeImage(quantize_info,image); quantize_info=DestroyQuantizeInfo(quantize_info); diff --git a/MagickCore/image.h b/MagickCore/image.h index 928b78ad3..705439089 100644 --- a/MagickCore/image.h +++ b/MagickCore/image.h @@ -287,11 +287,11 @@ struct _Image MagickBooleanType sync; - size_t - map; + ChannelType + channel_mask; PixelChannelMap - **channel_map; + *channel_map; void *cache; diff --git a/MagickCore/magick-config.h b/MagickCore/magick-config.h index 2726a74e3..60334d7b9 100644 --- a/MagickCore/magick-config.h +++ b/MagickCore/magick-config.h @@ -12,7 +12,9 @@ /* #undef AUTOTRACE_DELEGATE */ /* Define if coders and filters are to be built as modules. */ -/* #undef BUILD_MODULES */ +#ifndef MAGICKCORE_BUILD_MODULES +#define MAGICKCORE_BUILD_MODULES 1 +#endif /* Define if you have the bzip2 library */ #ifndef MAGICKCORE_BZLIB_DELEGATE @@ -78,7 +80,9 @@ #endif /* Define if you have FFTW library */ -/* #undef FFTW_DELEGATE */ +#ifndef MAGICKCORE_FFTW_DELEGATE +#define MAGICKCORE_FFTW_DELEGATE 1 +#endif /* Location of filter modules */ #ifndef MAGICKCORE_FILTER_PATH @@ -432,15 +436,15 @@ #endif /* Define if you have the header file. */ -#ifndef MAGICKCORE_HAVE_LCMS2_H -#define MAGICKCORE_HAVE_LCMS2_H 1 -#endif +/* #undef HAVE_LCMS2_H */ /* Define if you have the header file. */ /* #undef HAVE_LCMS2_LCMS2_H */ /* Define if you have the header file. */ -/* #undef HAVE_LCMS_H */ +#ifndef MAGICKCORE_HAVE_LCMS_H +#define MAGICKCORE_HAVE_LCMS_H 1 +#endif /* Define if you have the header file. */ /* #undef HAVE_LCMS_LCMS_H */ @@ -1163,7 +1167,9 @@ #endif /* Define if you have JBIG library */ -/* #undef JBIG_DELEGATE */ +#ifndef MAGICKCORE_JBIG_DELEGATE +#define MAGICKCORE_JBIG_DELEGATE 1 +#endif /* Define if you have JPEG version 2 "Jasper" library */ #ifndef MAGICKCORE_JP2_DELEGATE @@ -1192,7 +1198,9 @@ #endif /* Define if you have LQR library */ -/* #undef LQR_DELEGATE */ +#ifndef MAGICKCORE_LQR_DELEGATE +#define MAGICKCORE_LQR_DELEGATE 1 +#endif /* Define if using libltdl to support dynamically loadable modules */ #ifndef MAGICKCORE_LTDL_DELEGATE @@ -1204,7 +1212,7 @@ /* Define to the system default library search path. */ #ifndef MAGICKCORE_LT_DLSEARCH_PATH -#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/atlas:/usr/lib/llvm:/usr/lib64/llvm:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib64/tcl8.5:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2" +#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/xulrunner-2" #endif /* The archive extension */ @@ -1255,7 +1263,9 @@ /* #undef NO_MINUS_C_MINUS_O */ /* Define if you have OPENEXR library */ -/* #undef OPENEXR_DELEGATE */ +#ifndef MAGICKCORE_OPENEXR_DELEGATE +#define MAGICKCORE_OPENEXR_DELEGATE 1 +#endif /* Define to the address where bug reports for this package should be sent. */ #ifndef MAGICKCORE_PACKAGE_BUGREPORT @@ -1310,7 +1320,9 @@ #endif /* Define if you have RSVG library */ -/* #undef RSVG_DELEGATE */ +#ifndef MAGICKCORE_RSVG_DELEGATE +#define MAGICKCORE_RSVG_DELEGATE 1 +#endif /* Define to the type of arg 1 for `select'. */ #ifndef MAGICKCORE_SELECT_TYPE_ARG1 @@ -1447,7 +1459,9 @@ /* Define if you have WEBP library */ -/* #undef WEBP_DELEGATE */ +#ifndef MAGICKCORE_WEBP_DELEGATE +#define MAGICKCORE_WEBP_DELEGATE 1 +#endif /* Define to use the Windows GDI32 library */ /* #undef WINGDI32_DELEGATE */ @@ -1456,7 +1470,9 @@ /* #undef WITH_DMALLOC */ /* Define if you have WMF library */ -/* #undef WMF_DELEGATE */ +#ifndef MAGICKCORE_WMF_DELEGATE +#define MAGICKCORE_WMF_DELEGATE 1 +#endif /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h index fee52f4d9..4a6dc33a0 100644 --- a/MagickCore/pixel-accessor.h +++ b/MagickCore/pixel-accessor.h @@ -29,60 +29,60 @@ extern "C" { static inline Quantum GetPixelAlpha(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][AlphaPixelChannel].channel]); + return(pixel[image->channel_map[AlphaPixelChannel].channel]); } static inline PixelTrait GetPixelAlphaTraits(const Image *image) { - return(image->channel_map[image->map][AlphaPixelChannel].traits); + return(image->channel_map[AlphaPixelChannel].traits); } static inline Quantum GetPixelBlack(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][BlackPixelChannel].channel]); + return(pixel[image->channel_map[BlackPixelChannel].channel]); } static inline PixelTrait GetPixelBlackTraits(const Image *image) { - return(image->channel_map[image->map][BlackPixelChannel].traits); + return(image->channel_map[BlackPixelChannel].traits); } static inline Quantum GetPixelBlue(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][BluePixelChannel].channel]); + return(pixel[image->channel_map[BluePixelChannel].channel]); } static inline PixelTrait GetPixelBlueTraits(const Image *image) { - return(image->channel_map[image->map][BluePixelChannel].traits); + return(image->channel_map[BluePixelChannel].traits); } static inline Quantum GetPixelCb(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][CbPixelChannel].channel]); + return(pixel[image->channel_map[CbPixelChannel].channel]); } static inline PixelTrait GetPixelCbTraits(const Image *image) { - return(image->channel_map[image->map][CbPixelChannel].traits); + return(image->channel_map[CbPixelChannel].traits); } static inline Quantum GetPixelChannel(const Image *image, const PixelChannel channel,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][channel].channel]); + return(pixel[image->channel_map[channel].channel]); } static inline PixelChannel GetPixelChannelMapChannel(const Image *image, const PixelChannel channel) { - return(image->channel_map[image->map][channel].channel); + return(image->channel_map[channel].channel); } static inline PixelTrait GetPixelChannelMapTraits(const Image *image, const PixelChannel channel) { - return(image->channel_map[image->map][channel].traits); + return(image->channel_map[channel].traits); } static inline size_t GetPixelChannels(const Image *image) @@ -92,52 +92,52 @@ static inline size_t GetPixelChannels(const Image *image) static inline Quantum GetPixelCr(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][CrPixelChannel].channel]); + return(pixel[image->channel_map[CrPixelChannel].channel]); } static inline PixelTrait GetPixelCrTraits(const Image *image) { - return(image->channel_map[image->map][CrPixelChannel].traits); + return(image->channel_map[CrPixelChannel].traits); } static inline Quantum GetPixelCyan(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][CyanPixelChannel].channel]); + return(pixel[image->channel_map[CyanPixelChannel].channel]); } static inline PixelTrait GetPixelCyanTraits(const Image *image) { - return(image->channel_map[image->map][CyanPixelChannel].traits); + return(image->channel_map[CyanPixelChannel].traits); } static inline Quantum GetPixelGray(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][GrayPixelChannel].channel]); + return(pixel[image->channel_map[GrayPixelChannel].channel]); } static inline PixelTrait GetPixelGrayTraits(const Image *image) { - return(image->channel_map[image->map][GrayPixelChannel].traits); + return(image->channel_map[GrayPixelChannel].traits); } static inline Quantum GetPixelGreen(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][GreenPixelChannel].channel]); + return(pixel[image->channel_map[GreenPixelChannel].channel]); } static inline PixelTrait GetPixelGreenTraits(const Image *image) { - return(image->channel_map[image->map][GreenPixelChannel].traits); + return(image->channel_map[GreenPixelChannel].traits); } static inline Quantum GetPixelIndex(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][IndexPixelChannel].channel]); + return(pixel[image->channel_map[IndexPixelChannel].channel]); } static inline PixelTrait GetPixelIndexTraits(const Image *image) { - return(image->channel_map[image->map][IndexPixelChannel].traits); + return(image->channel_map[IndexPixelChannel].traits); } static inline Quantum GetPixelInfoIntensity(const PixelInfo *pixel_info) @@ -168,12 +168,12 @@ static inline Quantum GetPixelInfoLuminance(const PixelInfo *pixel_info) static inline Quantum GetPixelMagenta(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][MagentaPixelChannel].channel]); + return(pixel[image->channel_map[MagentaPixelChannel].channel]); } static inline PixelTrait GetPixelMagentaTraits(const Image *image) { - return(image->channel_map[image->map][MagentaPixelChannel].traits); + return(image->channel_map[MagentaPixelChannel].traits); } static inline size_t GetPixelMetaChannels(const Image *image) @@ -188,12 +188,12 @@ static inline size_t GetPixelMetacontentExtent(const Image *image) static inline Quantum GetPixelRed(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][RedPixelChannel].channel]); + return(pixel[image->channel_map[RedPixelChannel].channel]); } static inline PixelTrait GetPixelRedTraits(const Image *image) { - return(image->channel_map[image->map][RedPixelChannel].traits); + return(image->channel_map[RedPixelChannel].traits); } static inline void GetPixelPacket(const Image *image,const Quantum *pixel, @@ -229,27 +229,27 @@ static inline Quantum GetPixelPacketIntensity(const PixelPacket *pixel) static inline PixelTrait GetPixelTraits(const Image *image, const PixelChannel channel) { - return(image->channel_map[image->map][channel].traits); + return(image->channel_map[channel].traits); } static inline Quantum GetPixelY(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][YPixelChannel].channel]); + return(pixel[image->channel_map[YPixelChannel].channel]); } static inline PixelTrait GetPixelYTraits(const Image *image) { - return(image->channel_map[image->map][YPixelChannel].traits); + return(image->channel_map[YPixelChannel].traits); } static inline Quantum GetPixelYellow(const Image *image,const Quantum *pixel) { - return(pixel[image->channel_map[image->map][YellowPixelChannel].channel]); + return(pixel[image->channel_map[YellowPixelChannel].channel]); } static inline PixelTrait GetPixelYellowTraits(const Image *image) { - return(image->channel_map[image->map][YellowPixelChannel].traits); + return(image->channel_map[YellowPixelChannel].traits); } static inline MagickBooleanType IsPixelEquivalent(const Image *image, @@ -429,57 +429,57 @@ static inline void SetPacketPixelInfo(const Image *image, static inline void SetPixelAlpha(const Image *image,const Quantum alpha, Quantum *pixel) { - pixel[image->channel_map[image->map][AlphaPixelChannel].channel]=alpha; + pixel[image->channel_map[AlphaPixelChannel].channel]=alpha; } static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][AlphaPixelChannel].traits=traits; + image->channel_map[AlphaPixelChannel].traits=traits; } static inline void SetPixelBlack(const Image *image,const Quantum black, Quantum *pixel) { - pixel[image->channel_map[image->map][BlackPixelChannel].channel]=black; + pixel[image->channel_map[BlackPixelChannel].channel]=black; } static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][BlackPixelChannel].traits=traits; + image->channel_map[BlackPixelChannel].traits=traits; } static inline void SetPixelBlue(const Image *image,const Quantum blue, Quantum *pixel) { - pixel[image->channel_map[image->map][BluePixelChannel].channel]=blue; + pixel[image->channel_map[BluePixelChannel].channel]=blue; } static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][BluePixelChannel].traits=traits; + image->channel_map[BluePixelChannel].traits=traits; } static inline void SetPixelCb(const Image *image,const Quantum cb, Quantum *pixel) { - pixel[image->channel_map[image->map][CbPixelChannel].channel]=cb; + pixel[image->channel_map[CbPixelChannel].channel]=cb; } static inline void SetPixelCbTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][CbPixelChannel].traits=traits; + image->channel_map[CbPixelChannel].traits=traits; } static inline void SetPixelChannel(const Image *image, const PixelChannel channel,const Quantum quantum,Quantum *pixel) { - pixel[image->channel_map[image->map][channel].channel]=quantum; + pixel[image->channel_map[channel].channel]=quantum; } static inline void SetPixelChannelMapChannel(const Image *image, const PixelChannel channel,const PixelChannel channels) { - image->channel_map[image->map][channel].channel=channels; + image->channel_map[channel].channel=channels; } static inline void SetPixelChannels(Image *image,const size_t number_channels) @@ -490,63 +490,63 @@ static inline void SetPixelChannels(Image *image,const size_t number_channels) static inline void SetPixelChannelTraits(Image *image, const PixelChannel channel,const PixelTrait traits) { - image->channel_map[image->map][channel].traits=traits; + image->channel_map[channel].traits=traits; } static inline void SetPixelChannelMapTraits(Image *image, const PixelChannel channel,const PixelTrait traits) { - image->channel_map[image->map][channel].traits=traits; + image->channel_map[channel].traits=traits; } static inline void SetPixelCr(const Image *image,const Quantum cr, Quantum *pixel) { - pixel[image->channel_map[image->map][CrPixelChannel].channel]=cr; + pixel[image->channel_map[CrPixelChannel].channel]=cr; } static inline void SetPixelCrTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][CrPixelChannel].traits=traits; + image->channel_map[CrPixelChannel].traits=traits; } static inline void SetPixelCyan(const Image *image,const Quantum cyan, Quantum *pixel) { - pixel[image->channel_map[image->map][CyanPixelChannel].channel]=cyan; + pixel[image->channel_map[CyanPixelChannel].channel]=cyan; } static inline void SetPixelGray(const Image *image,const Quantum gray, Quantum *pixel) { - pixel[image->channel_map[image->map][GrayPixelChannel].channel]=gray; + pixel[image->channel_map[GrayPixelChannel].channel]=gray; } static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][GrayPixelChannel].traits=traits; + image->channel_map[GrayPixelChannel].traits=traits; } static inline void SetPixelGreen(const Image *image,const Quantum green, Quantum *pixel) { - pixel[image->channel_map[image->map][GreenPixelChannel].channel]=green; + pixel[image->channel_map[GreenPixelChannel].channel]=green; } static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][GreenPixelChannel].traits=traits; + image->channel_map[GreenPixelChannel].traits=traits; } static inline void SetPixelIndex(const Image *image,const Quantum index, Quantum *pixel) { - pixel[image->channel_map[image->map][IndexPixelChannel].channel]=index; + pixel[image->channel_map[IndexPixelChannel].channel]=index; } static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][IndexPixelChannel].traits=traits; + image->channel_map[IndexPixelChannel].traits=traits; } static inline void SetPixelInfo(const Image *image,const Quantum *pixel, @@ -590,13 +590,13 @@ static inline void SetPixelInfoPacket(const Image *image, static inline void SetPixelMagenta(const Image *image,const Quantum magenta, Quantum *pixel) { - pixel[image->channel_map[image->map][MagentaPixelChannel].channel]= + pixel[image->channel_map[MagentaPixelChannel].channel]= magenta; } static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][MagentaPixelChannel].traits=traits; + image->channel_map[MagentaPixelChannel].traits=traits; } static inline void SetPixelMetaChannels(Image *image, @@ -613,12 +613,12 @@ static inline void SetPixelMetacontentExtent(Image *image,const size_t extent) static inline void SetPixelRed(const Image *image,const Quantum red, Quantum *pixel) { - pixel[image->channel_map[image->map][RedPixelChannel].channel]=red; + pixel[image->channel_map[RedPixelChannel].channel]=red; } static inline void SetPixelRedTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][RedPixelChannel].traits=traits; + image->channel_map[RedPixelChannel].traits=traits; } static inline void SetPixelPacket(const Image *image,const PixelPacket *packet, @@ -644,23 +644,23 @@ static inline void SetPixelPixelInfo(const Image *image, static inline void SetPixelYellow(const Image *image,const Quantum yellow, Quantum *pixel) { - pixel[image->channel_map[image->map][YellowPixelChannel].channel]= + pixel[image->channel_map[YellowPixelChannel].channel]= yellow; } static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][YellowPixelChannel].traits=traits; + image->channel_map[YellowPixelChannel].traits=traits; } static inline void SetPixelY(const Image *image,const Quantum y,Quantum *pixel) { - pixel[image->channel_map[image->map][YPixelChannel].channel]=y; + pixel[image->channel_map[YPixelChannel].channel]=y; } static inline void SetPixelYTraits(Image *image,const PixelTrait traits) { - image->channel_map[image->map][YPixelChannel].traits=traits; + image->channel_map[YPixelChannel].traits=traits; } static inline Quantum GetPixelIntensity(const Image *image,const Quantum *pixel) diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c index a1f5462d9..b5c226256 100644 --- a/MagickCore/pixel.c +++ b/MagickCore/pixel.c @@ -83,35 +83,24 @@ % % The format of the AcquirePixelChannelMap() method is: % -% PixelChannelMap **AcquirePixelChannelMap(void) +% PixelChannelMap *AcquirePixelChannelMap(void) % */ -MagickExport PixelChannelMap **AcquirePixelChannelMap(void) +MagickExport PixelChannelMap *AcquirePixelChannelMap(void) { PixelChannelMap - **channel_map; + *channel_map; register ssize_t i; - channel_map=(PixelChannelMap **) AcquireAlignedMemory(MaxPixelChannelMaps, - sizeof(**channel_map)); - if (channel_map == (PixelChannelMap **) NULL) + channel_map=(PixelChannelMap *) AcquireQuantumMemory(MaxPixelChannels, + sizeof(*channel_map)); + if (channel_map == (PixelChannelMap *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); - for (i=0; i < MaxPixelChannelMaps; i++) - { - register ssize_t - j; - - channel_map[i]=(PixelChannelMap *) AcquireQuantumMemory(MaxPixelChannels, - sizeof(*channel_map[i])); - if (channel_map[i] == (PixelChannelMap *) NULL) - ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); - (void) ResetMagickMemory(channel_map[i],0,MaxPixelChannels* - sizeof(*channel_map[i])); - for (j=0; j < MaxPixelChannels; j++) - channel_map[i][j].channel=(PixelChannel) j; - } + (void) ResetMagickMemory(channel_map,0,MaxPixelChannels*sizeof(*channel_map)); + for (i=0; i < MaxPixelChannels; i++) + channel_map[i].channel=(PixelChannel) i; return(channel_map); } @@ -130,30 +119,24 @@ MagickExport PixelChannelMap **AcquirePixelChannelMap(void) % % The format of the ClonePixelChannelMap() method is: % -% PixelChannelMap **ClonePixelChannelMap( -% PixelChannelMap **channel_map) +% PixelChannelMap *ClonePixelChannelMap(PixelChannelMap *channel_map) % % A description of each parameter follows: % % o channel_map: the pixel component map. % */ -MagickExport PixelChannelMap **ClonePixelChannelMap( - PixelChannelMap **channel_map) +MagickExport PixelChannelMap *ClonePixelChannelMap(PixelChannelMap *channel_map) { PixelChannelMap - **clone_map; - - register ssize_t - i; + *clone_map; - assert(channel_map != (PixelChannelMap **) NULL); + assert(channel_map != (PixelChannelMap *) NULL); clone_map=AcquirePixelChannelMap(); - if (clone_map == (PixelChannelMap **) NULL) - return((PixelChannelMap **) NULL); - for (i=0; i < MaxPixelChannelMaps; i++) - (void) CopyMagickMemory(clone_map[i],channel_map[i],MaxPixelChannels* - sizeof(*channel_map[i])); + if (clone_map == (PixelChannelMap *) NULL) + return((PixelChannelMap *) NULL); + (void) CopyMagickMemory(clone_map,channel_map,MaxPixelChannels* + sizeof(*channel_map)); return(clone_map); } @@ -208,23 +191,19 @@ MagickExport PixelInfo *ClonePixelInfo(const PixelInfo *pixel) % % The format of the DestroyPixelChannelMap() method is: % -% PixelChannelMap **DestroyPixelChannelMap(PixelChannelMap **channel_map) +% PixelChannelMap *DestroyPixelChannelMap(PixelChannelMap *channel_map) % % A description of each parameter follows: % % o channel_map: the pixel component map. % */ -MagickExport PixelChannelMap **DestroyPixelChannelMap( - PixelChannelMap **channel_map) +MagickExport PixelChannelMap *DestroyPixelChannelMap( + PixelChannelMap *channel_map) { - register ssize_t - i; - - assert(channel_map != (PixelChannelMap **) NULL); - for (i=0; i < MaxPixelChannelMaps; i++) - channel_map[i]=(PixelChannelMap *) RelinquishMagickMemory(channel_map[i]); - return((PixelChannelMap **) RelinquishMagickMemory(channel_map)); + assert(channel_map != (PixelChannelMap *) NULL); + channel_map=(PixelChannelMap *) RelinquishMagickMemory(channel_map); + return((PixelChannelMap *) RelinquishMagickMemory(channel_map)); } /* @@ -3567,6 +3546,75 @@ MagickExport MagickBooleanType ImportImagePixels(Image *image, % % % % % % ++ I n i t i a l i z e P i x e l C h a n n e l M a p % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% InitializePixelChannelMap() defines the standard pixel component map. +% +% The format of the InitializePixelChannelMap() method is: +% +% void InitializePixelChannelMap(Image *image) +% +% A description of each parameter follows: +% +% o image: the image. +% +*/ +MagickExport void InitializePixelChannelMap(Image *image) +{ + PixelChannel + alpha_channel; + + register ssize_t + i; + + for (i=0; i < (ssize_t) MaxPixelChannels; i++) + { + SetPixelChannelMapChannel(image,(PixelChannel) i,(PixelChannel) i); + SetPixelChannelMapTraits(image,(PixelChannel) i,UndefinedPixelTrait); + } + image->sync=MagickTrue; + image->number_channels=4; + if (0 && image->colorspace == GRAYColorspace) + image->number_channels=2; + if (image->colorspace == CMYKColorspace) + image->number_channels++; + if (image->storage_class == PseudoClass) + image->number_channels++; + for (i=0; i < (ssize_t) image->number_channels; i++) + SetPixelChannelMapTraits(image,(PixelChannel) i,(PixelTrait) + UpdatePixelTrait); + alpha_channel=GetPixelChannelMapChannel(image,AlphaPixelChannel); + if (image->matte != MagickFalse) + for (i=0; i < (ssize_t) image->number_channels; i++) + if ((PixelChannel) i != alpha_channel) + SetPixelChannelMapTraits(image,(PixelChannel) i,(PixelTrait) + (UpdatePixelTrait | BlendPixelTrait)); + if (0 && image->colorspace == GRAYColorspace) + { + image->number_channels=2; + SetPixelChannelMapChannel(image,GreenPixelChannel,RedPixelChannel); + SetPixelChannelMapChannel(image,BluePixelChannel,RedPixelChannel); + } + if (image->storage_class == PseudoClass) + { + SetPixelChannelMapChannel(image,IndexPixelChannel,IndexPixelChannel); + SetPixelChannelMapTraits(image,IndexPixelChannel,CopyPixelTrait); + } + image->number_channels+=image->number_meta_channels; + for ( ; i < (ssize_t) image->number_channels; i++) + SetPixelChannelMapTraits(image,(PixelChannel) i,CopyPixelTrait); + SetPixelChannelMap(image,image->channel_mask); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % I n t e r p o l a t e P i x e l C h a n n e l % % % % % @@ -4844,69 +4892,6 @@ MagickExport MagickBooleanType IsFuzzyEquivalencePixelPacket(const Image *image, % % % % % % -% P o p P i x e l C h a n n e l M a p % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% PopPixelChannelMap() pops the pixel component map. -% -% The format of the PopPixelChannelMap method is: -% -% void PopPixelChannelMap(Image *image) -% -% A description of each parameter follows: -% -% o image: the image. -% -*/ -MagickExport void PopPixelChannelMap(Image *image) -{ - image->map--; - if (image->map < 0) - ThrowFatalException(ResourceLimitFatalError,"PixelChannelMapStack"); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % -% P u s h P i x e l C h a n n e l M a p % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% PushPixelChannelMap() pushes the pixel channel map from the specified -% channel mask. -% -% The format of the PushPixelChannelMap method is: -% -% void PushPixelChannelMap(Image *image,const ChannelType channel_mask) -% -% A description of each parameter follows: -% -% o image: the image. -% -% o channel_mask: the channel mask. -% -*/ -MagickExport void PushPixelChannelMap(Image *image, - const ChannelType channel_mask) -{ - image->map++; - if (image->map >= MaxPixelChannelMaps) - ThrowFatalException(ResourceLimitFatalError,"PixelChannelMapStack"); - SetPixelChannelMap(image,channel_mask); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % S e t P i x e l C h a n n e l M a p % % % % % @@ -4947,65 +4932,35 @@ MagickExport void SetPixelChannelMap(Image *image,const ChannelType mask) % % % % % % -+ S t a n d a r d P i x e l C h a n n e l M a p % +% S e t P i x e l C h a n n e l M a s k % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% StandardPixelChannelMap() defines the standard pixel component map. +% SetPixelChannelMask() sets the pixel channel mask from the specified +% channel mask. % -% The format of the StandardPixelChannelMap() method is: +% The format of the SetPixelChannelMask method is: % -% void StandardPixelChannelMap(Image *image) +% ChannelType SetPixelChannelMask(Image *image, +% const ChannelType channel_mask) % % A description of each parameter follows: % % o image: the image. % +% o channel_mask: the channel mask. +% */ -MagickExport void StandardPixelChannelMap(Image *image) +MagickExport ChannelType SetPixelChannelMask(Image *image, + const ChannelType channel_mask) { - PixelChannel - alpha_channel; - - register ssize_t - i; + ChannelType + mask; - for (i=0; i < (ssize_t) MaxPixelChannels; i++) - { - SetPixelChannelMapChannel(image,(PixelChannel) i,(PixelChannel) i); - SetPixelChannelMapTraits(image,(PixelChannel) i,UndefinedPixelTrait); - } - image->sync=MagickTrue; - image->number_channels=4; - if (0 && image->colorspace == GRAYColorspace) - image->number_channels=2; - if (image->colorspace == CMYKColorspace) - image->number_channels++; - if (image->storage_class == PseudoClass) - image->number_channels++; - for (i=0; i < (ssize_t) image->number_channels; i++) - SetPixelChannelMapTraits(image,(PixelChannel) i,(PixelTrait) - UpdatePixelTrait); - alpha_channel=GetPixelChannelMapChannel(image,AlphaPixelChannel); - if (image->matte != MagickFalse) - for (i=0; i < (ssize_t) image->number_channels; i++) - if ((PixelChannel) i != alpha_channel) - SetPixelChannelMapTraits(image,(PixelChannel) i,(PixelTrait) - (UpdatePixelTrait | BlendPixelTrait)); - if (0 && image->colorspace == GRAYColorspace) - { - image->number_channels=2; - SetPixelChannelMapChannel(image,GreenPixelChannel,RedPixelChannel); - SetPixelChannelMapChannel(image,BluePixelChannel,RedPixelChannel); - } - if (image->storage_class == PseudoClass) - { - SetPixelChannelMapChannel(image,IndexPixelChannel,IndexPixelChannel); - SetPixelChannelMapTraits(image,IndexPixelChannel,CopyPixelTrait); - } - image->number_channels+=image->number_meta_channels; - for ( ; i < (ssize_t) image->number_channels; i++) - SetPixelChannelMapTraits(image,(PixelChannel) i,CopyPixelTrait); + mask=image->channel_mask; + image->channel_mask=channel_mask; + SetPixelChannelMap(image,channel_mask); + return(mask); } diff --git a/MagickCore/pixel.h b/MagickCore/pixel.h index 0917049ab..08ef29db2 100644 --- a/MagickCore/pixel.h +++ b/MagickCore/pixel.h @@ -26,7 +26,6 @@ extern "C" { #include #define MaxPixelChannels 32 -#define MaxPixelChannelMaps 8 typedef enum { @@ -141,6 +140,9 @@ typedef struct _PixelPacket typedef struct _CacheView CacheView_; +extern MagickExport ChannelType + SetPixelChannelMask(Image *,const ChannelType); + extern MagickExport MagickBooleanType ExportImagePixels(const Image *,const ssize_t,const ssize_t,const size_t, const size_t,const char *,const StorageType,void *,ExceptionInfo *), @@ -159,18 +161,16 @@ extern MagickExport MagickBooleanType const PixelPacket *); extern MagickExport PixelChannelMap - **AcquirePixelChannelMap(void), - **ClonePixelChannelMap(PixelChannelMap **), - **DestroyPixelChannelMap(PixelChannelMap **); + *AcquirePixelChannelMap(void), + *ClonePixelChannelMap(PixelChannelMap *), + *DestroyPixelChannelMap(PixelChannelMap *); extern MagickExport PixelInfo *ClonePixelInfo(const PixelInfo *); extern MagickExport void - StandardPixelChannelMap(Image *), + InitializePixelChannelMap(Image *), GetPixelInfo(const Image *,PixelInfo *), - PopPixelChannelMap(Image *), - PushPixelChannelMap(Image *,const ChannelType), SetPixelChannelMap(Image *,const ChannelType); #if defined(__cplusplus) || defined(c_plusplus) diff --git a/MagickCore/version.h b/MagickCore/version.h index 9d9c7577e..fcf2f8185 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -27,7 +27,7 @@ extern "C" { */ #define MagickPackageName "ImageMagick" #define MagickCopyright "Copyright (C) 1999-2011 ImageMagick Studio LLC" -#define MagickSVNRevision "4982" +#define MagickSVNRevision "exported" #define MagickLibVersion 0x700 #define MagickLibVersionText "7.0.0" #define MagickLibVersionNumber 5,0,0 diff --git a/MagickWand/composite.c b/MagickWand/composite.c index 91fff1890..329abca23 100644 --- a/MagickWand/composite.c +++ b/MagickWand/composite.c @@ -111,6 +111,9 @@ static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image, Image *composite_image,CompositeOptions *composite_options, ExceptionInfo *exception) { + ChannelType + channel_mask; + MagickStatusType status; @@ -122,25 +125,25 @@ static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); assert(exception != (ExceptionInfo *) NULL); status=MagickTrue; - PushPixelChannelMap(composite_image,composite_options->channel); + channel_mask=SetPixelChannelMask(composite_image,composite_options->channel); if (composite_image != (Image *) NULL) { assert(composite_image->signature == MagickSignature); - switch( composite_options->compose ) - { - case BlendCompositeOp: - case BlurCompositeOp: - case DisplaceCompositeOp: - case DistortCompositeOp: - case DissolveCompositeOp: - case ModulateCompositeOp: - case ThresholdCompositeOp: - (void) SetImageArtifact(composite_image,"compose:args", - composite_options->compose_args); - break; - default: - break; - } + switch (composite_options->compose) + { + case BlendCompositeOp: + case BlurCompositeOp: + case DisplaceCompositeOp: + case DistortCompositeOp: + case DissolveCompositeOp: + case ModulateCompositeOp: + case ThresholdCompositeOp: + (void) SetImageArtifact(composite_image,"compose:args", + composite_options->compose_args); + break; + default: + break; + } /* Composite image. */ @@ -218,7 +221,7 @@ static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image, GetImageException(*image,exception); } } - PopPixelChannelMap(composite_image); + (void) SetPixelChannelMap(composite_image,channel_mask); return(status != 0 ? MagickTrue : MagickFalse); } diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 3b2e855f1..a58c1b389 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -4043,7 +4043,8 @@ Fx(ref,...) expression[MaxTextExtent]; ChannelType - channel; + channel, + channel_mask; ExceptionInfo *exception; @@ -4149,10 +4150,10 @@ Fx(ref,...) } } } - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=FxImage(image,expression,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); if ((image == (Image *) NULL) || (exception->severity >= ErrorException)) goto PerlException; for ( ; image; image=image->next) @@ -7204,7 +7205,8 @@ Mogrify(ref,...) message[MaxTextExtent]; ChannelType - channel; + channel, + channel_mask; CompositeOperator compose; @@ -7491,11 +7493,11 @@ Mogrify(ref,...) argument_list[0].integer_reference=UniformNoise; if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=AddNoiseImage(image,(NoiseType) argument_list[0].integer_reference,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 4: /* Colorize */ @@ -7557,11 +7559,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=BlurImage(image,geometry_info.rho,geometry_info.sigma, exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 7: /* Chop */ @@ -7717,11 +7719,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho, (size_t) geometry_info.sigma,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 19: /* Minify */ @@ -7752,11 +7754,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=StatisticImage(image,NonpeakStatistic,(size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 22: /* Roll */ @@ -7844,11 +7846,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=SharpenImage(image,geometry_info.rho,geometry_info.sigma, exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 28: /* Shear */ @@ -8354,7 +8356,7 @@ Mogrify(ref,...) geometry.y); flags=ParseGravityGeometry(image,composite_geometry,&geometry, exception); - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); if (attribute_flag[8] == 0) /* no rotate */ CompositeImage(image,compose,composite_image,geometry.x,geometry.y); else @@ -8377,7 +8379,7 @@ Mogrify(ref,...) else image->mask=DestroyImage(image->mask); } - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 36: /* Contrast */ @@ -8640,9 +8642,9 @@ Mogrify(ref,...) { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); EqualizeImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 40: /* Gamma */ @@ -8726,11 +8728,10 @@ Mogrify(ref,...) invert=MagickFalse; if (attribute_flag[6] != 0) invert=(MagickBooleanType) argument_list[6].integer_reference; - PushPixelChannelMap(image,AlphaChannel); + channel_mask=SetPixelChannelMask(image,AlphaChannel); (void) FloodfillPaintImage(image,draw_info,&target,geometry.x, geometry.y,invert); - PopPixelChannelMap(image); - StandardPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); draw_info=DestroyDrawInfo(draw_info); break; } @@ -8780,19 +8781,19 @@ Mogrify(ref,...) argument_list[0].integer_reference=0; if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) NegateImage(image,argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 45: /* Normalize */ { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); NormalizeImage(image,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 46: /* NumberColors */ @@ -8822,9 +8823,9 @@ Mogrify(ref,...) invert=MagickFalse; if (attribute_flag[4] != 0) invert=(MagickBooleanType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) OpaquePaintImage(image,&target,&fill_color,invert); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 48: /* Quantize */ @@ -8961,10 +8962,10 @@ Mogrify(ref,...) op=(MagickEvaluateOperator) argument_list[1].integer_reference; if (attribute_flag[2] != MagickFalse) channel=(ChannelType) argument_list[2].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) EvaluateImage(image,op,argument_list[0].real_reference, exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 56: /* Transparent */ @@ -9009,9 +9010,9 @@ Mogrify(ref,...) channel=(ChannelType) argument_list[1].integer_reference; threshold=SiPrefixToDouble(argument_list[0].string_reference, QuantumRange); - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) BilevelImage(image,threshold); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 58: /* Charcoal */ @@ -9063,9 +9064,9 @@ Mogrify(ref,...) { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) SeparateImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 63: /* Stereo */ @@ -9118,11 +9119,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma, exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 67: /* Convolve */ @@ -9173,11 +9174,11 @@ Mogrify(ref,...) if (kernel == (KernelInfo *) NULL) break; } - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); kernel->bias=image->bias; image=ConvolveImage(image,kernel,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); kernel=DestroyKernelInfo(kernel); break; } @@ -9275,11 +9276,11 @@ Mogrify(ref,...) geometry_info.psi=argument_list[4].real_reference; if (attribute_flag[5] != 0) channel=(ChannelType) argument_list[5].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma, geometry_info.xi,geometry_info.psi,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 70: /* MotionBlur */ @@ -9301,11 +9302,11 @@ Mogrify(ref,...) geometry_info.xi=argument_list[3].real_reference; if (attribute_flag[4] != 0) channel=(ChannelType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma, geometry_info.xi,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 71: /* OrderedDither */ @@ -9314,10 +9315,10 @@ Mogrify(ref,...) argument_list[0].string_reference="o8x8"; if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) OrderedPosterizeImage(image,argument_list[0].string_reference, exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 72: /* Shave */ @@ -9372,9 +9373,9 @@ Mogrify(ref,...) argument_list[0].real_reference=argument_list[5].real_reference; attribute_flag[0]=attribute_flag[5]; } - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) LevelImage(image,black_point,white_point,gamma,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 74: /* Clip */ @@ -9594,10 +9595,10 @@ Mogrify(ref,...) argument_list[0].string_reference="50%"; if (attribute_flag[2] != 0) channel=(ChannelType) argument_list[2].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); BlackThresholdImage(image,argument_list[0].string_reference, exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 81: /* WhiteThreshold */ @@ -9606,10 +9607,10 @@ Mogrify(ref,...) argument_list[0].string_reference="50%"; if (attribute_flag[2] != 0) channel=(ChannelType) argument_list[2].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); WhiteThresholdImage(image,argument_list[0].string_reference, exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 82: /* RadialBlur */ @@ -9625,10 +9626,10 @@ Mogrify(ref,...) geometry_info.rho=argument_list[1].real_reference; if (attribute_flag[2] != 0) channel=(ChannelType) argument_list[2].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=RadialBlurImage(image,geometry_info.rho,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 83: /* Thumbnail */ @@ -9667,9 +9668,9 @@ Mogrify(ref,...) { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) SeparateImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 87: /* Splice */ @@ -9778,10 +9779,10 @@ Mogrify(ref,...) if (attribute_flag[4] != 0) sharpen=argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho, geometry_info.sigma); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 93: /* Extent */ @@ -9876,9 +9877,9 @@ Mogrify(ref,...) white_point=argument_list[2].real_reference; if (attribute_flag[4] != 0) channel=(ChannelType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) ContrastStretchImage(image,black_point,white_point,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 96: /* Sans0 */ @@ -9904,11 +9905,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=AdaptiveSharpenImage(image,geometry_info.rho, geometry_info.sigma,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 99: /* Transpose */ @@ -9980,11 +9981,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma, exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 103: /* Sketch */ @@ -10163,10 +10164,10 @@ Mogrify(ref,...) invert=MagickFalse; if (attribute_flag[7] != 0) invert=(MagickBooleanType) argument_list[7].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) FloodfillPaintImage(image,draw_info,&target,geometry.x, geometry.y,invert); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); draw_info=DestroyDrawInfo(draw_info); break; } @@ -10226,9 +10227,9 @@ Mogrify(ref,...) } if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) ClutImage(image,argument_list[0].image_reference,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 114: /* LiquidRescale */ @@ -10336,11 +10337,11 @@ Mogrify(ref,...) argument_list[2].integer_reference); if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=SparseColorImage(image,method,number_coordinates,coordinates, exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); if ((attribute_flag[2] != 0) && (image != (Image *) NULL)) virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel); coordinates=(double *) RelinquishMagickMemory(coordinates); @@ -10410,11 +10411,11 @@ Mogrify(ref,...) geometry_info.xi=argument_list[3].integer_reference;; if (attribute_flag[4] != 0) channel=(ChannelType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma, geometry_info.xi,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 122: /* HaldClut */ @@ -10427,9 +10428,9 @@ Mogrify(ref,...) } if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) HaldClutImage(image,argument_list[0].image_reference); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 123: /* BlueShift */ @@ -10466,18 +10467,18 @@ Mogrify(ref,...) { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) AutoGammaImage(image,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 128: /* AutoLevel */ { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) AutoLevelImage(image,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 129: /* LevelColors */ @@ -10496,19 +10497,19 @@ Mogrify(ref,...) &white_point,exception); if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) LevelImageColors(image,&black_point,&white_point, argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 130: /* Clamp */ { if (attribute_flag[0] != 0) channel=(ChannelType) argument_list[0].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) ClampImage(image); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 132: /* BrightnessContrast */ @@ -10533,9 +10534,9 @@ Mogrify(ref,...) contrast=argument_list[2].real_reference; if (attribute_flag[4] != 0) channel=(ChannelType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); (void) BrightnessContrastImage(image,brightness,contrast,exception); - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 133: /* Morphology */ @@ -10562,10 +10563,10 @@ Mogrify(ref,...) iterations=1; if (attribute_flag[3] != 0) iterations=argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=MorphologyImage(image,method,iterations,kernel,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); kernel=DestroyKernelInfo(kernel); break; } @@ -10641,11 +10642,11 @@ Mogrify(ref,...) geometry_info.sigma=argument_list[2].real_reference; if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho, (size_t) geometry_info.sigma,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } case 137: /* Statistic */ @@ -10669,11 +10670,11 @@ Mogrify(ref,...) channel=(ChannelType) argument_list[3].integer_reference; if (attribute_flag[4] != 0) statistic=(StatisticType) argument_list[4].integer_reference; - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); image=StatisticImage(image,statistic,(size_t) geometry_info.rho, (size_t) geometry_info.sigma,exception); if (image != (Image *) NULL) - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); break; } } @@ -13234,7 +13235,8 @@ SetPixel(ref,...) *attribute; ChannelType - channel; + channel, + channel_mask; ExceptionInfo *exception; @@ -13395,7 +13397,7 @@ SetPixel(ref,...) } } (void) SetImageStorageClass(image,DirectClass,exception); - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); q=GetAuthenticPixels(image,region.x,region.y,1,1,exception); if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) || (SvTYPE(av) != SVt_PVAV)) @@ -13449,7 +13451,7 @@ SetPixel(ref,...) } (void) SyncAuthenticPixels(image,exception); } - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); PerlException: InheritPerlException(exception,perl_exception); diff --git a/coders/msl.c b/coders/msl.c index 04d2df3c7..5b0750fe6 100644 --- a/coders/msl.c +++ b/coders/msl.c @@ -605,6 +605,9 @@ static void MSLStartElement(void *context,const xmlChar *tag, ChannelType channel; + ChannelType + channel_mask; + char key[MaxTextExtent], *value; @@ -736,10 +739,10 @@ static void MSLStartElement(void *context,const xmlChar *tag, } } } - PushPixelChannelMap(msl_info->image[n],channel); + channel_mask=SetPixelChannelMask(msl_info->image[n],channel); noise_image=AddNoiseImage(msl_info->image[n],noise, &msl_info->image[n]->exception); - PopPixelChannelMap(msl_info->image[n]); + (void) SetPixelChannelMap(msl_info->image[n],channel_mask); if (noise_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); @@ -1229,10 +1232,10 @@ static void MSLStartElement(void *context,const xmlChar *tag, } } } - PushPixelChannelMap(msl_info->image[n],channel); + channel_mask=SetPixelChannelMask(msl_info->image[n],channel); blur_image=BlurImage(msl_info->image[n],geometry_info.rho, geometry_info.sigma,&msl_info->image[n]->exception); - PopPixelChannelMap(msl_info->image[n]); + (void) SetPixelChannelMap(msl_info->image[n],channel_mask); if (blur_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); @@ -2053,7 +2056,7 @@ static void MSLStartElement(void *context,const xmlChar *tag, geometry.y); flags=ParseGravityGeometry(image,composite_geometry,&geometry, &exception); - PushPixelChannelMap(image,channel); + channel_mask=SetPixelChannelMask(image,channel); if (rotate_image == (Image *) NULL) CompositeImage(image,compose,composite_image,geometry.x,geometry.y); else @@ -2067,7 +2070,7 @@ static void MSLStartElement(void *context,const xmlChar *tag, CompositeImage(image,compose,rotate_image,geometry.x,geometry.y); rotate_image=DestroyImage(rotate_image); } - PopPixelChannelMap(image); + (void) SetPixelChannelMask(image,channel_mask); composite_image=DestroyImage(composite_image); break; } @@ -3735,11 +3738,11 @@ static void MSLStartElement(void *context,const xmlChar *tag, draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); draw_info->fill.alpha=ClampToQuantum(opacity); - PushPixelChannelMap(msl_info->image[n],AlphaChannel); + channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel); (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target, geometry.x,geometry.y,paint_method == FloodfillMethod ? MagickFalse : MagickTrue); - PopPixelChannelMap(msl_info->image[n]); + (void) SetPixelChannelMap(msl_info->image[n],channel_mask); draw_info=DestroyDrawInfo(draw_info); break; } @@ -4035,10 +4038,10 @@ static void MSLStartElement(void *context,const xmlChar *tag, } } } - PushPixelChannelMap(msl_info->image[n],channel); + channel_mask=SetPixelChannelMask(msl_info->image[n],channel); (void) NegateImage(msl_info->image[n],gray, &msl_info->image[n]->exception); - PopPixelChannelMap(msl_info->image[n]); + (void) SetPixelChannelMap(msl_info->image[n],channel_mask); break; } if (LocaleCompare((const char *) tag,"normalize") == 0) @@ -4228,10 +4231,10 @@ static void MSLStartElement(void *context,const xmlChar *tag, } } } - PushPixelChannelMap(msl_info->image[n],channel); + channel_mask=SetPixelChannelMask(msl_info->image[n],channel); (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color, MagickFalse); - PopPixelChannelMap(msl_info->image[n]); + (void) SetPixelChannelMap(msl_info->image[n],channel_mask); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); diff --git a/coders/png.c b/coders/png.c index 8b559d824..b2b772ebd 100644 --- a/coders/png.c +++ b/coders/png.c @@ -11555,6 +11555,9 @@ static MagickBooleanType WriteOneJNGImage(MngInfo *mng_info, if (transparent) { + ChannelType + channel_mask; + jng_color_type=14; /* Create JPEG blob, image, and image_info */ @@ -11577,9 +11580,9 @@ static MagickBooleanType WriteOneJNGImage(MngInfo *mng_info, ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); (void) CopyMagickString(jpeg_image->magick,"JPEG",MaxTextExtent); - PushPixelChannelMap(jpeg_image,AlphaChannel); + channel_mask=SetPixelChannelMask(jpeg_image,AlphaChannel); status=SeparateImage(jpeg_image); - PopPixelChannelMap(jpeg_image); + (void) SetPixelChannelMap(jpeg_image,channel_mask); jpeg_image->matte=MagickFalse; if (jng_quality >= 1000) diff --git a/coders/ps3.c b/coders/ps3.c index e009f90a1..74e723ed1 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -427,6 +427,9 @@ static MagickBooleanType SerializeImageIndexes(const ImageInfo *image_info, static MagickBooleanType WritePS3MaskImage(const ImageInfo *image_info, Image *image,const CompressionType compression) { + ChannelType + channel_mask; + char buffer[MaxTextExtent]; @@ -515,9 +518,9 @@ static MagickBooleanType WritePS3MaskImage(const ImageInfo *image_info, mask_image=CloneImage(image,0,0,MagickTrue,&image->exception); if (mask_image == (Image *) NULL) ThrowWriterException(CoderError,image->exception.reason); - PushPixelChannelMap(mask_image,AlphaChannel); + channel_mask=SetPixelChannelMask(mask_image,AlphaChannel); status=SeparateImage(mask_image); - PopPixelChannelMap(mask_image); + (void) SetPixelChannelMap(mask_image,channel_mask); if (status == MagickFalse) { mask_image=DestroyImage(mask_image);