From 010d7d107ddf63501993c10081f891891850dffe Mon Sep 17 00:00:00 2001 From: cristy Date: Wed, 31 Aug 2011 01:02:48 +0000 Subject: [PATCH] --- MagickCore/animate.c | 4 - MagickCore/display.c | 2 - MagickCore/effect.c | 5 +- MagickCore/enhance.c | 21 ++- MagickCore/fx.c | 5 +- MagickCore/resize.c | 35 ++--- MagickCore/shear.c | 15 +- MagickCore/stream.c | 10 +- MagickCore/threshold.c | 5 +- MagickCore/transform.c | 345 +++++++++++++++++++++++++++++------------ MagickCore/version.h | 2 +- 11 files changed, 284 insertions(+), 165 deletions(-) diff --git a/MagickCore/animate.c b/MagickCore/animate.c index a76471308..aba1d86e5 100644 --- a/MagickCore/animate.c +++ b/MagickCore/animate.c @@ -314,10 +314,6 @@ MagickExport MagickBooleanType AnimateImages(const ImageInfo *image_info, resource_info.immutable=MagickTrue; argv[0]=AcquireString(GetClientName()); (void) XAnimateImages(display,&resource_info,argv,1,images,exception); - SetErrorHandler((ErrorHandler) NULL); - SetWarningHandler((WarningHandler) NULL); - SetErrorHandler((ErrorHandler) NULL); - SetWarningHandler((WarningHandler) NULL); argv[0]=DestroyString(argv[0]); (void) XCloseDisplay(display); XDestroyResourceInfo(&resource_info); diff --git a/MagickCore/display.c b/MagickCore/display.c index 85c4583db..1c93b078d 100644 --- a/MagickCore/display.c +++ b/MagickCore/display.c @@ -1695,8 +1695,6 @@ MagickExport MagickBooleanType DisplayImages(const ImageInfo *image_info, image=GetImageFromList(images,i % GetImageListLength(images)); (void) XDisplayImage(display,&resource_info,argv,1,&image,&state,exception); } - SetErrorHandler((ErrorHandler) NULL); - SetWarningHandler((WarningHandler) NULL); argv[0]=DestroyString(argv[0]); (void) XCloseDisplay(display); XDestroyResourceInfo(&resource_info); diff --git a/MagickCore/effect.c b/MagickCore/effect.c index a61be98e3..9c57202a1 100644 --- a/MagickCore/effect.c +++ b/MagickCore/effect.c @@ -1341,11 +1341,10 @@ MagickExport Image *ConvolveImage(const Image *image, v; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); convolve_traits=GetPixelChannelMapTraits(convolve_image,channel); - if (convolve_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (convolve_traits == UndefinedPixelTrait)) continue; if ((convolve_traits & CopyPixelTrait) != 0) { diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index d9f5fd22e..d6c70a265 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -383,13 +383,14 @@ MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image, traits; clut_traits=GetPixelChannelMapTraits(clut_image,(PixelChannel) i); - if (clut_traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(clut_image,(PixelChannel) i); traits=GetPixelChannelMapTraits(clut_image,channel); - if ((traits & UpdatePixelTrait) != 0) - q[channel]=ClampToQuantum(clut_map[ScaleQuantumToMap(q[channel])* - GetPixelChannels(clut_image)+channel]); + if ((traits == UndefinedPixelTrait) || + (clut_traits == UndefinedPixelTrait) || + ((traits & UpdatePixelTrait) == 0)) + continue; + q[channel]=ClampToQuantum(clut_map[ScaleQuantumToMap(q[channel])* + GetPixelChannels(clut_image)+channel]); } q+=GetPixelChannels(image); } @@ -1389,11 +1390,10 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception) *restrict r; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); enhance_traits=GetPixelChannelMapTraits(enhance_image,channel); - if (enhance_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (enhance_traits == UndefinedPixelTrait)) continue; q[channel]=p[center+i]; if ((enhance_traits & CopyPixelTrait) != 0) @@ -2195,9 +2195,8 @@ MagickExport MagickBooleanType LevelImage(Image *image,const double black_point, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; - if ((traits & UpdatePixelTrait) == 0) + if ((traits == UndefinedPixelTrait) || + ((traits & UpdatePixelTrait) == 0)) continue; q[i]=LevelQuantum(q[i]); } diff --git a/MagickCore/fx.c b/MagickCore/fx.c index f9ab8a393..1d64588ef 100644 --- a/MagickCore/fx.c +++ b/MagickCore/fx.c @@ -3034,11 +3034,10 @@ MagickExport Image *FxImage(const Image *image,const char *expression, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); fx_traits=GetPixelChannelMapTraits(fx_image,channel); - if (fx_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (fx_traits == UndefinedPixelTrait)) continue; if ((fx_traits & CopyPixelTrait) != 0) { diff --git a/MagickCore/resize.c b/MagickCore/resize.c index ac79ff48d..e88ff06b3 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -1244,11 +1244,10 @@ MagickExport Image *AdaptiveResizeImage(const Image *image, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); resize_traits=GetPixelChannelMapTraits(resize_image,channel); - if (resize_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (resize_traits == UndefinedPixelTrait)) continue; if ((resize_traits & CopyPixelTrait) != 0) { @@ -1801,11 +1800,10 @@ MagickExport Image *LiquidRescaleImage(const Image *image,const size_t columns, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); rescale_traits=GetPixelChannelMapTraits(rescale_image,channel); - if (rescale_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (rescale_traits == UndefinedPixelTrait)) continue; q[channel]=ClampToQuantum(QuantumRange*packet[i]); } @@ -2233,11 +2231,10 @@ static MagickBooleanType HorizontalFilter(const ResizeFilter *resize_filter, k; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); resize_traits=GetPixelChannelMapTraits(resize_image,channel); - if (resize_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (resize_traits == UndefinedPixelTrait)) continue; if ((resize_traits & CopyPixelTrait) != 0) { @@ -2446,11 +2443,10 @@ static MagickBooleanType VerticalFilter(const ResizeFilter *resize_filter, k; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); resize_traits=GetPixelChannelMapTraits(resize_image,channel); - if (resize_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (resize_traits == UndefinedPixelTrait)) continue; if ((resize_traits & CopyPixelTrait) != 0) { @@ -2753,11 +2749,10 @@ MagickExport Image *SampleImage(const Image *image,const size_t columns, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); sample_traits=GetPixelChannelMapTraits(sample_image,channel); - if (sample_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (sample_traits == UndefinedPixelTrait)) continue; q[channel]=p[x_offset[x]*GetPixelChannels(image)+i]; } @@ -3052,11 +3047,10 @@ MagickExport Image *ScaleImage(const Image *image,const size_t columns, for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); scale_traits=GetPixelChannelMapTraits(scale_image,channel); - if (scale_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (scale_traits == UndefinedPixelTrait)) continue; if ((scale_traits & BlendPixelTrait) == 0) { @@ -3141,11 +3135,10 @@ MagickExport Image *ScaleImage(const Image *image,const size_t columns, for (i=0; i < (ssize_t) GetPixelChannels(scale_image); i++) { traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); scale_traits=GetPixelChannelMapTraits(scale_image,channel); - if (scale_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (scale_traits == UndefinedPixelTrait)) continue; if ((scale_traits & BlendPixelTrait) == 0) { diff --git a/MagickCore/shear.c b/MagickCore/shear.c index 6cf7d1eda..a36e0805d 100644 --- a/MagickCore/shear.c +++ b/MagickCore/shear.c @@ -1154,11 +1154,10 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); rotate_traits=GetPixelChannelMapTraits(rotate_image,channel); - if (rotate_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (rotate_traits == UndefinedPixelTrait)) continue; if ((rotate_traits & CopyPixelTrait) != 0) { @@ -1243,11 +1242,10 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); rotate_traits=GetPixelChannelMapTraits(rotate_image,channel); - if (rotate_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (rotate_traits == UndefinedPixelTrait)) continue; if ((rotate_traits & CopyPixelTrait) != 0) { @@ -1363,11 +1361,10 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, traits; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); rotate_traits=GetPixelChannelMapTraits(rotate_image,channel); - if (rotate_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (rotate_traits == UndefinedPixelTrait)) continue; if ((rotate_traits & CopyPixelTrait) != 0) { diff --git a/MagickCore/stream.c b/MagickCore/stream.c index 99a13e21e..d29bc4209 100644 --- a/MagickCore/stream.c +++ b/MagickCore/stream.c @@ -489,17 +489,15 @@ static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image, PixelPacket *pixel,ExceptionInfo *exception) { const Quantum - *p; + *q; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); *pixel=image->background_color; - p=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception); - if (p == (const Quantum *) NULL) + q=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception); + if (q != (const Quantum *) NULL) return(MagickFalse); - GetPixelPacket(image,p,pixel); - if (image->colorspace == CMYKColorspace) - pixel->black=GetPixelBlack(image,p); + GetPixelPacket(image,q,pixel); return(MagickTrue); } diff --git a/MagickCore/threshold.c b/MagickCore/threshold.c index b55ff7da7..d40778335 100644 --- a/MagickCore/threshold.c +++ b/MagickCore/threshold.c @@ -252,11 +252,10 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image, v; traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - if (traits == UndefinedPixelTrait) - continue; channel=GetPixelChannelMapChannel(image,(PixelChannel) i); threshold_traits=GetPixelChannelMapTraits(threshold_image,channel); - if (threshold_traits == UndefinedPixelTrait) + if ((traits == UndefinedPixelTrait) || + (threshold_traits == UndefinedPixelTrait)) continue; if ((threshold_traits & CopyPixelTrait) != 0) { diff --git a/MagickCore/transform.c b/MagickCore/transform.c index 0848029c3..e87b40bf7 100644 --- a/MagickCore/transform.c +++ b/MagickCore/transform.c @@ -514,6 +514,9 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, MagickOffsetType progress; + OffsetInfo + offset; + RectangleInfo bounding_box, page; @@ -612,8 +615,10 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, return((Image *) NULL); crop_image->page.width=image->page.width; crop_image->page.height=image->page.height; - if (((ssize_t) (bounding_box.x+bounding_box.width) > (ssize_t) image->page.width) || - ((ssize_t) (bounding_box.y+bounding_box.height) > (ssize_t) image->page.height)) + offset.x=(ssize_t) (bounding_box.x+bounding_box.width); + offset.y=(ssize_t) (bounding_box.y+bounding_box.height); + if ((offset.x > (ssize_t) image->page.width) || + (offset.y > (ssize_t) image->page.height)) { crop_image->page.width=bounding_box.width; crop_image->page.height=bounding_box.height; @@ -654,14 +659,26 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, } for (x=0; x < (ssize_t) crop_image->columns; x++) { - SetPixelRed(crop_image,GetPixelRed(image,p),q); - SetPixelGreen(crop_image,GetPixelGreen(image,p),q); - SetPixelBlue(crop_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(crop_image,GetPixelBlack(image,p),q); - SetPixelAlpha(crop_image,GetPixelAlpha(image,p),q); - if (image->storage_class == PseudoClass) - SetPixelIndex(crop_image,GetPixelIndex(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + crop_traits, + traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + crop_traits=GetPixelChannelMapTraits(crop_image,channel); + if ((traits == UndefinedPixelTrait) || + (crop_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(crop_image); } @@ -994,14 +1011,26 @@ MagickExport Image *ExcerptImage(const Image *image, } for (x=0; x < (ssize_t) excerpt_image->columns; x++) { - SetPixelRed(excerpt_image,GetPixelRed(image,p),q); - SetPixelGreen(excerpt_image,GetPixelGreen(image,p),q); - SetPixelBlue(excerpt_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(excerpt_image,GetPixelBlack(image,p),q); - if (image->storage_class == PseudoClass) - SetPixelIndex(excerpt_image,GetPixelIndex(image,p),q); - SetPixelAlpha(excerpt_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + excerpt_traits, + traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + excerpt_traits=GetPixelChannelMapTraits(excerpt_image,channel); + if ((traits == UndefinedPixelTrait) || + (excerpt_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(excerpt_image); } @@ -1182,14 +1211,26 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception) } for (x=0; x < (ssize_t) flip_image->columns; x++) { - SetPixelRed(flip_image,GetPixelRed(image,p),q); - SetPixelGreen(flip_image,GetPixelGreen(image,p),q); - SetPixelBlue(flip_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(flip_image,GetPixelBlack(image,p),q); - if (image->storage_class == PseudoClass) - SetPixelIndex(flip_image,GetPixelIndex(image,p),q); - SetPixelAlpha(flip_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + flip_traits, + traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + flip_traits=GetPixelChannelMapTraits(flip_image,channel); + if ((traits == UndefinedPixelTrait) || + (flip_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(flip_image); } @@ -1311,15 +1352,27 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception) q+=GetPixelChannels(flop_image)*flop_image->columns; for (x=0; x < (ssize_t) flop_image->columns; x++) { + register ssize_t + i; + q-=GetPixelChannels(flop_image); - SetPixelRed(flop_image,GetPixelRed(image,p),q); - SetPixelGreen(flop_image,GetPixelGreen(image,p),q); - SetPixelBlue(flop_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(flop_image,GetPixelBlack(image,p),q); - SetPixelAlpha(flop_image,GetPixelAlpha(image,p),q); - if (image->storage_class == PseudoClass) - SetPixelIndex(flop_image,GetPixelIndex(image,p),q); + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + flop_traits, + traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + flop_traits=GetPixelChannelMapTraits(flop_image,channel); + if ((traits == UndefinedPixelTrait) || + (flop_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); } if (SyncCacheViewAuthenticPixels(flop_view,exception) == MagickFalse) @@ -1427,12 +1480,26 @@ static inline MagickBooleanType CopyImageRegion(Image *destination, } for (x=0; x < (ssize_t) columns; x++) { - SetPixelRed(destination,GetPixelRed(source,p),q); - SetPixelGreen(destination,GetPixelGreen(source,p),q); - SetPixelBlue(destination,GetPixelBlue(source,p),q); - if (destination->colorspace == CMYKColorspace) - SetPixelBlack(destination,GetPixelBlack(source,p),q); - SetPixelAlpha(destination,GetPixelAlpha(source,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(source); i++) + { + PixelChannel + channel; + + PixelTrait + destination_traits, + source_traits; + + source_traits=GetPixelChannelMapTraits(source,(PixelChannel) i); + channel=GetPixelChannelMapChannel(source,(PixelChannel) i); + destination_traits=GetPixelChannelMapTraits(destination,channel); + if ((source_traits == UndefinedPixelTrait) || + (destination_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(source); q+=GetPixelChannels(destination); } @@ -1731,14 +1798,26 @@ MagickExport Image *SpliceImage(const Image *image, } for (x=0; x < splice_geometry.x; x++) { - SetPixelRed(splice_image,GetPixelRed(image,p),q); - SetPixelGreen(splice_image,GetPixelGreen(image,p),q); - SetPixelBlue(splice_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(splice_image,GetPixelBlack(image,p),q); - SetPixelAlpha(splice_image,OpaqueAlpha,q); - if (image->matte != MagickFalse) - SetPixelAlpha(splice_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + splice_traits, + traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + splice_traits=GetPixelChannelMapTraits(splice_image,channel); + if ((traits == UndefinedPixelTrait) || + (splice_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(splice_image); } @@ -1746,14 +1825,26 @@ MagickExport Image *SpliceImage(const Image *image, q+=GetPixelChannels(splice_image); for ( ; x < (ssize_t) splice_image->columns; x++) { - SetPixelRed(splice_image,GetPixelRed(image,p),q); - SetPixelGreen(splice_image,GetPixelGreen(image,p),q); - SetPixelBlue(splice_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(splice_image,GetPixelBlack(image,p),q); - SetPixelAlpha(splice_image,OpaqueAlpha,q); - if (image->matte != MagickFalse) - SetPixelAlpha(splice_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits, + splice_traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + splice_traits=GetPixelChannelMapTraits(splice_image,channel); + if ((traits == UndefinedPixelTrait) || + (splice_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(splice_image); } @@ -1803,14 +1894,26 @@ MagickExport Image *SpliceImage(const Image *image, } for (x=0; x < splice_geometry.x; x++) { - SetPixelRed(splice_image,GetPixelRed(image,p),q); - SetPixelGreen(splice_image,GetPixelGreen(image,p),q); - SetPixelBlue(splice_image,GetPixelBlue(image,p),q); - SetPixelAlpha(splice_image,OpaqueAlpha,q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(splice_image,GetPixelBlack(image,p),q); - if (image->matte != MagickFalse) - SetPixelAlpha(splice_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits, + splice_traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + splice_traits=GetPixelChannelMapTraits(splice_image,channel); + if ((traits == UndefinedPixelTrait) || + (splice_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(splice_image); } @@ -1818,14 +1921,26 @@ MagickExport Image *SpliceImage(const Image *image, q+=GetPixelChannels(splice_image); for ( ; x < (ssize_t) splice_image->columns; x++) { - SetPixelRed(splice_image,GetPixelRed(image,p),q); - SetPixelGreen(splice_image,GetPixelGreen(image,p),q); - SetPixelBlue(splice_image,GetPixelBlue(image,p),q); - SetPixelAlpha(splice_image,OpaqueAlpha,q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(splice_image,GetPixelBlack(image,p),q); - if (image->matte != MagickFalse) - SetPixelAlpha(splice_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits, + splice_traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + splice_traits=GetPixelChannelMapTraits(splice_image,channel); + if ((traits == UndefinedPixelTrait) || + (splice_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(splice_image); } @@ -1870,6 +1985,17 @@ MagickExport Image *SpliceImage(const Image *image, % % This should only be used for single images. % +% This function destroys what it assumes to be a single image list. +% If the input image is part of a larger list, all other images in that list +% will be simply 'lost', not destroyed. +% +% Also if the crop generates a list of images only the first image is resized. +% And finally if the crop succeeds and the resize failed, you will get a +% cropped image, as well as a 'false' or 'failed' report. +% +% This function and should probably be depreciated in favor of direct calls +% to CropImageToTiles() or ResizeImage(), as appropriate. +% % The format of the TransformImage method is: % % MagickBooleanType TransformImage(Image **image,const char *crop_geometry, @@ -1885,19 +2011,6 @@ MagickExport Image *SpliceImage(const Image *image, % o image_geometry: An image geometry string. This geometry defines the % final size of the image. % -*/ -/* - DANGER: This function destroys what it assumes to be a single image list. - If the input image is part of a larger list, all other images in that list - will be simply 'lost', not destroyed. - - Also if the crop generates a list of images only the first image is resized. - And finally if the crop succeeds and the resize failed, you will get a - cropped image, as well as a 'false' or 'failed' report. - - This function and should probably be depreciated in favor of direct calls - to CropImageToTiles() or ResizeImage(), as appropriate. - */ MagickExport MagickBooleanType TransformImage(Image **image, const char *crop_geometry,const char *image_geometry) @@ -2113,12 +2226,26 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception) } for (x=0; x < (ssize_t) image->columns; x++) { - SetPixelRed(transpose_image,GetPixelRed(image,p),q); - SetPixelGreen(transpose_image,GetPixelGreen(image,p),q); - SetPixelBlue(transpose_image,GetPixelBlue(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(transpose_image,GetPixelBlack(image,p),q); - SetPixelAlpha(transpose_image,GetPixelAlpha(image,p),q); + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits, + transpose_traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + transpose_traits=GetPixelChannelMapTraits(transpose_image,channel); + if ((traits == UndefinedPixelTrait) || + (transpose_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); q+=GetPixelChannels(transpose_image); } @@ -2226,17 +2353,17 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception) register const Quantum *restrict p; - register ssize_t - x; - register Quantum *restrict q; + register ssize_t + x; + if (status == MagickFalse) continue; p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); - q=QueueCacheViewAuthenticPixels(transverse_view,(ssize_t) (image->rows-y- - 1),0,1,transverse_image->rows,exception); + q=QueueCacheViewAuthenticPixels(transverse_view,(ssize_t) (image->rows-y-1), + 0,1,transverse_image->rows,exception); if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL)) { status=MagickFalse; @@ -2245,13 +2372,27 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception) q+=GetPixelChannels(transverse_image)*image->columns; for (x=0; x < (ssize_t) image->columns; x++) { + register ssize_t + i; + q-=GetPixelChannels(transverse_image); - SetPixelRed(transverse_image,GetPixelRed(image,p),q); - SetPixelGreen(transverse_image,GetPixelGreen(image,p),q); - SetPixelBlue(transverse_image,GetPixelBlue(image,p),q); - SetPixelAlpha(transverse_image,GetPixelAlpha(image,p),q); - if (image->colorspace == CMYKColorspace) - SetPixelBlack(transverse_image,GetPixelBlack(image,p),q); + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits, + transverse_traits; + + traits=GetPixelChannelMapTraits(image,(PixelChannel) i); + channel=GetPixelChannelMapChannel(image,(PixelChannel) i); + transverse_traits=GetPixelChannelMapTraits(transverse_image,channel); + if ((traits == UndefinedPixelTrait) || + (transverse_traits == UndefinedPixelTrait)) + continue; + q[channel]=p[i]; + } p+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(transverse_view,exception); diff --git a/MagickCore/version.h b/MagickCore/version.h index e6d836361..ec6c14560 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -34,7 +34,7 @@ extern "C" { #define MagickLibAddendum "-0" #define MagickLibInterface 5 #define MagickLibMinInterface 5 -#define MagickReleaseDate "2011-08-28" +#define MagickReleaseDate "2011-08-30" #define MagickChangeDate "20110801" #define MagickAuthoritativeURL "http://www.imagemagick.org" #if defined(MAGICKCORE_OPENMP_SUPPORT) -- 2.40.0