From 4190655b07a1f0849abae240c26b49884cc1ccd2 Mon Sep 17 00:00:00 2001 From: anthony Date: Fri, 7 Oct 2011 12:15:27 +0000 Subject: [PATCH] Remove "colors" from image_info. Only use is in coder/jpeg.c. Added artifact "jpeg:colors" to enable jpeg library quantization. --- MagickCore/image.c | 4 ---- MagickCore/image.h | 6 ++---- MagickWand/mogrify.c | 5 ----- coders/jpeg.c | 15 ++++++++------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/MagickCore/image.c b/MagickCore/image.c index 8b559d7a6..79198c9f8 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -962,7 +962,6 @@ MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info) clone_info->transparent_color=image_info->transparent_color; clone_info->dither=image_info->dither; clone_info->monochrome=image_info->monochrome; - clone_info->colors=image_info->colors; clone_info->colorspace=image_info->colorspace; clone_info->type=image_info->type; clone_info->orientation=image_info->orientation; @@ -4206,9 +4205,6 @@ MagickExport MagickBooleanType SyncImageSettings(const ImageInfo *image_info, if (option != (const char *) NULL) (void) QueryColorCompliance(option,AllCompliance,&image->border_color, &image->exception); - option=GetImageOption(image_info,"colors"); - if (option != (const char *) NULL) - image->colors=StringToUnsignedLong(option); option=GetImageOption(image_info,"compose"); if (option != (const char *) NULL) image->compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, diff --git a/MagickCore/image.h b/MagickCore/image.h index 23e1f897f..01e5b7025 100644 --- a/MagickCore/image.h +++ b/MagickCore/image.h @@ -169,7 +169,8 @@ struct _Image columns, /* physical size of image */ rows, depth, /* depth of image on read/write */ - colors; /* size of color table on read */ + colors; /* Size of color table, or actual color count if known */ + /* Only valid if image is not DirectClass */ PixelPacket *colormap, @@ -406,9 +407,6 @@ struct _ImageInfo dither, /* dither enable-disable */ monochrome; /* read/write pcl,pdf,ps,xps as monocrome image */ - size_t - colors; /* record the user requested color reduction! */ - ColorspaceType colorspace; diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 2a13ce5fc..31503ef02 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -6283,11 +6283,6 @@ WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); break; } - if (LocaleCompare("colors",option+1) == 0) - { - image_info->colors=StringToUnsignedLong(argv[i+1]); - break; - } if (LocaleCompare("colorspace",option+1) == 0) { if (*option == '+') diff --git a/coders/jpeg.c b/coders/jpeg.c index 060c8ba15..64e9e59f0 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1120,13 +1120,12 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, image->compression=JPEGCompression; image->interlace=JPEGInterlace; #endif - if ((image_info->colors > 8) && (image_info->colors <= 256)) + option=GetImageOption(image_info,"jpeg:colors"); + if (option != (const char *) NULL) { - /* - Let the JPEG library quantize for us. - */ + /* Let the JPEG library quantize the image */ jpeg_info.quantize_colors=MagickTrue; - jpeg_info.desired_number_of_colors=(int) image_info->colors; + jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option); } option=GetImageOption(image_info,"jpeg:block-smoothing"); if (option != (const char *) NULL) @@ -1180,8 +1179,10 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, image->colorspace=YCbCrColorspace; if (jpeg_info.out_color_space == JCS_CMYK) image->colorspace=CMYKColorspace; - if ((image_info->colors != 0) && (image_info->colors <= 256)) - if (AcquireImageColormap(image,image_info->colors,exception) == MagickFalse) + option=GetImageOption(image_info,"jpeg:colors"); + if (option != (const char *) NULL) + if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) + == MagickFalse) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); if ((jpeg_info.output_components == 1) && (jpeg_info.quantize_colors == MagickFalse)) -- 2.40.0