From: cristy Date: Sun, 8 Jan 2012 00:32:49 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6437 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=100b8d9c4f78f07a52dac4aec46abfe4c2013196;p=imagemagick --- diff --git a/Magick++/lib/Magick++/Include.h b/Magick++/lib/Magick++/Include.h index 908547499..5cbb9dfbb 100644 --- a/Magick++/lib/Magick++/Include.h +++ b/Magick++/lib/Magick++/Include.h @@ -482,7 +482,7 @@ namespace Magick using MagickCore::StorageType; using MagickCore::CharPixel; using MagickCore::ShortPixel; - using MagickCore::IntegerPixel; + using MagickCore::LongLongPixel; using MagickCore::FloatPixel; using MagickCore::DoublePixel; diff --git a/MagickCore/resize.c b/MagickCore/resize.c index 689889e5f..7119a8fa4 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -763,9 +763,9 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, { SincFast, 3.0, 1.0, 0.0, 0.0 }, /* lanczos, Sharpened */ { SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos, 2-lobed */ { SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos2, sharpened */ - { CubicBC, 2.0, 1.1685777620836932, - 0.37821575509399867, 0.31089212245300067 } - /* Robidoux: Keys cubic close to Lanczos2D sharpened */ + { CubicBC, 2.0, 1.1685777620836932, 0.37821575509399867, + 0.31089212245300067 } + /* Robidoux: Keys cubic close to Lanczos2D sharpened */ }; /* The known zero crossings of the Jinc() or more accurately the Jinc(x*PI) @@ -831,11 +831,16 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact); if ((UndefinedFilter < option) && (option < SentinelFilter)) - { /* Raw filter request - no window function. */ + { + /* + Raw filter request - no window function. + */ filter_type=(FilterTypes) option; window_type=BoxFilter; } - /* Filter override with a specific window function. */ + /* + Filter override with a specific window function. + */ artifact=GetImageArtifact(image,"filter:window"); if (artifact != (const char *) NULL) { @@ -846,7 +851,9 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, } else { - /* Window specified, but no filter function? Assume Sinc/Jinc. */ + /* + Window specified, but no filter function? Assume Sinc/Jinc. + */ artifact=GetImageArtifact(image,"filter:window"); if (artifact != (const char *) NULL) { @@ -862,53 +869,67 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, } } } - - /* Assign the real functions to use for the filters selected. */ + /* + Assign the real functions to use for the filters selected. + */ resize_filter->filter=filters[filter_type].function; resize_filter->support=filters[filter_type].lobes; resize_filter->window=filters[window_type].function; resize_filter->scale=filters[window_type].scale; resize_filter->signature=MagickSignature; - - /* Filter Modifications for orthogonal/cylindrical usage */ + /* + Filter Modifications for orthogonal/cylindrical usage. + */ if (cylindrical != MagickFalse) switch (filter_type) { case BoxFilter: - /* Support for Cylindrical Box should be sqrt(2)/2 */ + { + /* + Support for Cylindrical Box should be sqrt(2)/2. + */ resize_filter->support=(MagickRealType) MagickSQ1_2; break; + } case LanczosFilter: case LanczosSharpFilter: case Lanczos2Filter: case Lanczos2SharpFilter: + { + /* + Number of lobes (support window size) remain unchanged. + */ resize_filter->filter=filters[JincFilter].function; resize_filter->window=filters[JincFilter].function; resize_filter->scale=filters[JincFilter].scale; - /* number of lobes (support window size) remain unchanged */ break; + } default: break; } - /* Global Sharpening (regardless of orthoginal/cylindrical) */ + /* + Global Sharpening (regardless of orthoginal/cylindrical). + */ switch (filter_type) { case LanczosSharpFilter: + { resize_filter->blur*=0.9812505644269356; break; + } case Lanczos2SharpFilter: + { resize_filter->blur*=0.9549963639785485; break; + } default: break; } - /* - ** Other Expert Option Modifications + Expert Option Modifications. */ - /* User Gaussian Sigma Override - no support change */ - value = 0.5; /* guassian sigma default, half pixel */ + value=0.5; /* guassian sigma default, half pixel */ if ( GaussianFilter ) { artifact=GetImageArtifact(image,"filter:sigma"); if (artifact != (const char *) NULL) @@ -1071,23 +1092,24 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, GetMagickPrecision(), (double)resize_filter->blur); if (filter_type == GaussianFilter) (void) FormatLocaleFile(stdout,"# gaussian_sigma = %.*g\n", - GetMagickPrecision(), (double)value); + GetMagickPrecision(), (double)value); if ( filter_type == KaiserFilter ) (void) FormatLocaleFile(stdout,"# kaiser_alpha = %.*g\n", - GetMagickPrecision(), (double)value); + GetMagickPrecision(), (double)value); (void) FormatLocaleFile(stdout,"# practical_support = %.*g\n", GetMagickPrecision(), (double)support); if ( filter_type == CubicFilter || window_type == CubicFilter ) (void) FormatLocaleFile(stdout,"# B,C = %.*g,%.*g\n", - GetMagickPrecision(),(double)B, GetMagickPrecision(),(double)C); + GetMagickPrecision(),(double)B, GetMagickPrecision(),(double)C); (void) FormatLocaleFile(stdout,"\n"); /* Output values of resulting filter graph -- for graphing filter result. */ for (x=0.0; x <= support; x+=0.01f) - (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",x,GetMagickPrecision(), - (double) GetResizeFilterWeight(resize_filter,x)); + (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",x, + GetMagickPrecision(),(double) GetResizeFilterWeight(resize_filter, + x)); /* A final value so gnuplot can graph the 'stop' properly. */ (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",support, GetMagickPrecision(),0.0); diff --git a/MagickCore/stream.c b/MagickCore/stream.c index cb0f3c6d3..3aff7b9d5 100644 --- a/MagickCore/stream.c +++ b/MagickCore/stream.c @@ -454,10 +454,10 @@ static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image, q=GetAuthenticPixelsStream(image,x,y,1,1,exception); if (q != (Quantum *) NULL) { - pixel[RedPixelChannel]=image->background_color.red; - pixel[GreenPixelChannel]=image->background_color.green; - pixel[BluePixelChannel]=image->background_color.blue; - pixel[AlphaPixelChannel]=image->background_color.alpha; + pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red); + pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green); + pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue); + pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha); return(MagickFalse); } for (i=0; i < (ssize_t) GetPixelChannels(image); i++) @@ -520,10 +520,10 @@ static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image, p=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception); if (p == (const Quantum *) NULL) { - pixel[RedPixelChannel]=image->background_color.red; - pixel[GreenPixelChannel]=image->background_color.green; - pixel[BluePixelChannel]=image->background_color.blue; - pixel[AlphaPixelChannel]=image->background_color.alpha; + pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red); + pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green); + pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue); + pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha); return(MagickFalse); } for (i=0; i < (ssize_t) GetPixelChannels(image); i++) @@ -1154,12 +1154,12 @@ static size_t WriteStreamImage(const Image *image,const void *pixels, stream_info=(StreamInfo *) image->client_data; switch (stream_info->storage_type) { - default: packet_size=sizeof(char); break; - case CharPixel: packet_size=sizeof(char); break; + default: packet_size=sizeof(unsigned char); break; + case CharPixel: packet_size=sizeof(unsigned char); break; case DoublePixel: packet_size=sizeof(double); break; case FloatPixel: packet_size=sizeof(float); break; - case IntegerPixel: packet_size=sizeof(int); break; - case LongPixel: packet_size=sizeof(ssize_t); break; + case LongPixel: packet_size=sizeof(unsigned int); break; + case LongLongPixel: packet_size=sizeof(MagickSizeType); break; case QuantumPixel: packet_size=sizeof(Quantum); break; case ShortPixel: packet_size=sizeof(unsigned short); break; } @@ -1421,7 +1421,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(unsigned char *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1435,7 +1435,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1450,9 +1450,9 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) - break; + break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); @@ -1465,7 +1465,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1477,7 +1477,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1491,7 +1491,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1506,7 +1506,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1519,7 +1519,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1585,7 +1585,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(double *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1602,7 +1602,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1621,7 +1621,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1639,7 +1639,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1652,7 +1652,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1669,7 +1669,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1688,7 +1688,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1704,7 +1704,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1777,7 +1777,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(float *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1794,7 +1794,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1813,7 +1813,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1831,7 +1831,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1844,7 +1844,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1861,7 +1861,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1880,7 +1880,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1896,7 +1896,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -1961,7 +1961,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - case IntegerPixel: + case LongPixel: { register unsigned int *q; @@ -1969,107 +1969,105 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(unsigned int *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p)); + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); p++; } break; } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=0U; + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=0; p++; } break; } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong( - GetPixelIntensity(image,p)); + *q++=ScaleQuantumToLong(GetPixelIntensity(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=(unsigned int) ScaleQuantumToLong((Quantum) - (GetPixelAlpha(image,p))); + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); p++; } break; } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=0U; + *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=0; p++; } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2082,45 +2080,44 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, case RedQuantum: case CyanQuantum: { - *q=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p)); + *q=ScaleQuantumToLong(GetPixelRed(image,p)); break; } case GreenQuantum: case MagentaQuantum: { - *q=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p)); + *q=ScaleQuantumToLong(GetPixelGreen(image,p)); break; } case BlueQuantum: case YellowQuantum: { - *q=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p)); + *q=ScaleQuantumToLong(GetPixelBlue(image,p)); break; } case AlphaQuantum: { - *q=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p)); + *q=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); break; } case OpacityQuantum: { - *q=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p)); + *q=ScaleQuantumToLong(GetPixelAlpha(image,p)); break; } case BlackQuantum: { if (image->colorspace == CMYKColorspace) - *q=(unsigned int) ScaleQuantumToLong(GetPixelBlack(image,p)); + *q=ScaleQuantumToLong(GetPixelBlack(image,p)); break; } case IndexQuantum: { - *q=(unsigned int) - ScaleQuantumToLong(GetPixelIntensity(image,p)); + *q=ScaleQuantumToLong(GetPixelIntensity(image,p)); break; } default: - *q=0; + break; } q++; } @@ -2128,113 +2125,114 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - case LongPixel: + case LongLongPixel: { - register size_t + register MagickSizeType *q; - q=(size_t *) stream_info->pixels; + q=(MagickSizeType *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=0; + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); + *q++=0U; p++; } break; } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelIntensity(image,p)); + *q++=ScaleQuantumToLongLong( + GetPixelIntensity(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); p++; } break; } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) { - *q++=ScaleQuantumToLong(GetPixelRed(image,p)); - *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); - *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); - *q++=0; + *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); + *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); + *q++=0U; p++; } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2247,44 +2245,44 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, case RedQuantum: case CyanQuantum: { - *q=ScaleQuantumToLong(GetPixelRed(image,p)); + *q=ScaleQuantumToLongLong(GetPixelRed(image,p)); break; } case GreenQuantum: case MagentaQuantum: { - *q=ScaleQuantumToLong(GetPixelGreen(image,p)); + *q=ScaleQuantumToLongLong(GetPixelGreen(image,p)); break; } case BlueQuantum: case YellowQuantum: { - *q=ScaleQuantumToLong(GetPixelBlue(image,p)); + *q=ScaleQuantumToLongLong(GetPixelBlue(image,p)); break; } case AlphaQuantum: { - *q=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); + *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); break; } case OpacityQuantum: { - *q=ScaleQuantumToLong(GetPixelAlpha(image,p)); + *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); break; } case BlackQuantum: { if (image->colorspace == CMYKColorspace) - *q=ScaleQuantumToLong(GetPixelBlack(image,p)); + *q=ScaleQuantumToLongLong(GetPixelBlack(image,p)); break; } case IndexQuantum: { - *q=ScaleQuantumToLong(GetPixelIntensity(image,p)); + *q=ScaleQuantumToLongLong(GetPixelIntensity(image,p)); break; } default: - break; + *q=0; } q++; } @@ -2300,7 +2298,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(Quantum *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2314,7 +2312,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2322,14 +2320,14 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, *q++=GetPixelBlue(image,p); *q++=GetPixelGreen(image,p); *q++=GetPixelRed(image,p); - *q++=(Quantum) (GetPixelAlpha(image,p)); + *q++=GetPixelAlpha(image,p); p++; } break; } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2344,7 +2342,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2356,7 +2354,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2370,7 +2368,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2378,14 +2376,14 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, *q++=GetPixelRed(image,p); *q++=GetPixelGreen(image,p); *q++=GetPixelBlue(image,p); - *q++=(Quantum) (GetPixelAlpha(image,p)); + *q++=GetPixelAlpha(image,p); p++; } break; } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2398,7 +2396,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2444,7 +2442,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } case IndexQuantum: { - *q=(GetPixelIntensity(image,p)); + *q=GetPixelIntensity(image,p); break; } default: @@ -2464,7 +2462,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, q=(unsigned short *) stream_info->pixels; if (LocaleCompare(stream_info->map,"BGR") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2478,7 +2476,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2493,7 +2491,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"BGRP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2508,7 +2506,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"I") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2520,7 +2518,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGB") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2534,7 +2532,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBA") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2549,7 +2547,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } if (LocaleCompare(stream_info->map,"RGBP") == 0) { - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) @@ -2562,7 +2560,7 @@ static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, } break; } - p=GetAuthenticPixelQueue(image); + p=GetVirtualPixelQueue(image); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) GetImageExtent(image); x++) diff --git a/coders/art.c b/coders/art.c index 6e9f0ec29..3dbc9afd9 100644 --- a/coders/art.c +++ b/coders/art.c @@ -102,9 +102,6 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) QuantumInfo *quantum_info; - QuantumType - quantum_type; - MagickBooleanType status; @@ -135,17 +132,13 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) image=DestroyImageList(image); return((Image *) NULL); } + image->colorspace=GRAYColorspace; image->depth=1; image->endian=MSBEndian; (void) ReadBlobLSBShort(image); image->columns=(size_t) ReadBlobLSBShort(image); (void) ReadBlobLSBShort(image); image->rows=(size_t) ReadBlobLSBShort(image); - /* - Initialize image colormap. - */ - if (AcquireImageColormap(image,2,exception) == MagickFalse) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); if (image_info->ping != MagickFalse) { (void) CloseBlob(image); @@ -154,12 +147,11 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Convert bi-level image to pixel packets. */ - quantum_type=IndexQuantum; quantum_info=AcquireQuantumInfo(image_info,image); if (quantum_info == (QuantumInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); pixels=GetQuantumPixels(quantum_info); - length=GetQuantumExtent(image,quantum_info,quantum_type); + length=GetQuantumExtent(image,quantum_info,GrayQuantum); for (y=0; y < (ssize_t) image->rows; y++) { register Quantum @@ -172,14 +164,14 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) if (count != (ssize_t) length) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, - quantum_type,pixels,exception); + GrayQuantum,pixels,exception); count=ReadBlob(image,(size_t) (-(ssize_t) length) & 0x01,pixels); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (SetImageProgress(image,LoadImageTag,y,image->rows) == MagickFalse) break; } - SetQuantumImageType(image,quantum_type); + SetQuantumImageType(image,GrayQuantum); quantum_info=DestroyQuantumInfo(quantum_info); if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", @@ -316,29 +308,23 @@ static MagickBooleanType WriteARTImage(const ImageInfo *image_info,Image *image, return(status); if ((image->columns > 65535UL) || (image->rows > 65535UL)) ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit"); + if (IsRGBColorspace(image->colorspace) == MagickFalse) + (void) TransformImageColorspace(image,RGBColorspace,exception); + (void) SetImageType(image,BilevelType,exception); image->endian=MSBEndian; image->depth=1; (void) WriteBlobLSBShort(image,0); (void) WriteBlobLSBShort(image,(unsigned short) image->columns); (void) WriteBlobLSBShort(image,0); (void) WriteBlobLSBShort(image,(unsigned short) image->rows); - if (IsRGBColorspace(image->colorspace) == MagickFalse) - (void) TransformImageColorspace(image,RGBColorspace,exception); - length=(image->columns+7)/8; - pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels)); - if (pixels == (unsigned char *) NULL) - ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); - /* - Convert image to a bi-level image. - */ - (void) SetImageType(image,BilevelType,exception); quantum_info=AcquireQuantumInfo(image_info,image); + pixels=GetQuantumPixels(quantum_info); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,exception); if (p == (const Quantum *) NULL) break; - (void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, + length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, GrayQuantum,pixels,exception); count=WriteBlob(image,length,pixels); if (count != (ssize_t) length) @@ -350,7 +336,6 @@ static MagickBooleanType WriteARTImage(const ImageInfo *image_info,Image *image, break; } quantum_info=DestroyQuantumInfo(quantum_info); - pixels=(unsigned char *) RelinquishMagickMemory(pixels); (void) CloseBlob(image); - return(MagickTrue); + return(status); } diff --git a/coders/cmyk.c b/coders/cmyk.c index d863291bd..3c1eee841 100644 --- a/coders/cmyk.c +++ b/coders/cmyk.c @@ -1215,7 +1215,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info, if (LocaleCompare(image_info->magick,"CMYKA") == 0) { quantum_type=CMYKAQuantum; - image->matte=MagickTrue; + if (image->matte == MagickFalse) + SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); } scene=0; do diff --git a/coders/rgb.c b/coders/rgb.c index 2259c3862..aef2619ae 100644 --- a/coders/rgb.c +++ b/coders/rgb.c @@ -1112,12 +1112,14 @@ static MagickBooleanType WriteRGBImage(const ImageInfo *image_info, if (LocaleCompare(image_info->magick,"RGBA") == 0) { quantum_type=RGBAQuantum; - image->matte=MagickTrue; + if (image->matte == MagickFalse) + SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); } if (LocaleCompare(image_info->magick,"RGBO") == 0) { quantum_type=RGBOQuantum; - image->matte=MagickTrue; + if (image->matte == MagickFalse) + SetImageAlphaChannel(image,QuantumRange-OpaqueAlphaChannel,exception); } scene=0; do diff --git a/tests/validate.c b/tests/validate.c index 0b373bb70..475a465db 100644 --- a/tests/validate.c +++ b/tests/validate.c @@ -465,8 +465,8 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info, Image *difference_image, - *reference_image, - *reconstruct_image; + *reconstruct_image, + *reference_image; MagickBooleanType status; @@ -476,14 +476,12 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info, j; size_t - length; + length, + test; unsigned char *blob; - size_t - test; - test=0; (void) FormatLocaleFile(stdout,"validate image formats in memory:\n"); for (i=0; reference_formats[i].magick != (char *) NULL; i++) diff --git a/tests/validate.h b/tests/validate.h index 27773b6d5..027866317 100644 --- a/tests/validate.h +++ b/tests/validate.h @@ -417,8 +417,8 @@ static const struct ReferenceStorage { CharPixel, sizeof(unsigned char) }, { DoublePixel, sizeof(double) }, { FloatPixel, sizeof(float) }, - { IntegerPixel, sizeof(unsigned int) }, - { LongPixel, sizeof(size_t) }, + { LongPixel, sizeof(unsigned int) }, + { LongLongPixel, sizeof(MagickSizeType) }, { ShortPixel, sizeof(unsigned short) }, { UndefinedPixel, 0 } };