From e2c4f18a7274c0c5c6231a2f3d73741a87d583fa Mon Sep 17 00:00:00 2001 From: cristy Date: Sat, 12 May 2012 14:11:53 +0000 Subject: [PATCH] --- MagickCore/channel.c | 2 +- MagickCore/colorspace-private.h | 10 ++++++++-- MagickCore/colorspace.c | 25 +++++++++++++++++++++++-- MagickCore/image.c | 2 +- MagickCore/paint.c | 2 +- coders/art.c | 2 +- coders/bgr.c | 4 ++-- coders/cin.c | 2 +- coders/cmyk.c | 4 ++-- coders/dpx.c | 11 ++++++----- coders/exr.c | 2 +- coders/fits.c | 2 +- coders/gray.c | 2 +- coders/hdr.c | 2 +- coders/ipl.c | 2 +- coders/jp2.c | 4 ++-- coders/jpeg.c | 8 ++++---- coders/mat.c | 2 +- coders/pcd.c | 4 ++-- coders/png.c | 2 +- coders/pnm.c | 18 +++++++++--------- coders/psd.c | 10 +++++----- coders/rgb.c | 4 ++-- coders/sct.c | 2 +- coders/tiff.c | 6 +++--- coders/uyvy.c | 2 +- coders/xcf.c | 4 ++-- coders/ycbcr.c | 4 ++-- coders/yuv.c | 2 +- tests/validate.c | 2 +- 30 files changed, 88 insertions(+), 60 deletions(-) diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 56473a15f..37f7a5dd9 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -645,7 +645,7 @@ MagickExport Image *SeparateImage(const Image *image, separate_image=DestroyImage(separate_image); return((Image *) NULL); } - separate_image->colorspace=GRAYColorspace; + SetImageColorspace(separate_image,GRAYColorspace,exception); separate_image->matte=MagickFalse; /* Separate image. diff --git a/MagickCore/colorspace-private.h b/MagickCore/colorspace-private.h index 9276a132f..6bc12ccb2 100644 --- a/MagickCore/colorspace-private.h +++ b/MagickCore/colorspace-private.h @@ -68,11 +68,17 @@ static inline MagickBooleanType IsGrayColorspace( return(MagickFalse); } +static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace) +{ + if (colorspace == RGBColorspace) + return(MagickTrue); + return(MagickFalse); +} + static inline MagickBooleanType IssRGBColorspace( const ColorspaceType colorspace) { - if ((IsGrayColorspace(colorspace) != MagickFalse) || - (colorspace == sRGBColorspace) || (colorspace == TransparentColorspace)) + if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace)) return(MagickTrue); return(MagickFalse); } diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index a8685d0bb..dbf6b4c3c 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -1251,6 +1251,26 @@ MagickExport MagickBooleanType SetImageColorspace(Image *image, const ColorspaceType colorspace,ExceptionInfo *exception) { image->colorspace=colorspace; + image->rendering_intent=UndefinedIntent; + image->gamma=1.000f; + ResetMagickMemory(&image->chromaticity,0,sizeof(image->chromaticity)); + if (IssRGBColorspace(colorspace) != MagickFalse) + { + image->rendering_intent=PerceptualIntent; + image->gamma=1.000f/2.200f; + image->chromaticity.red_primary.x=0.6400f; + image->chromaticity.red_primary.y=0.3300f; + image->chromaticity.red_primary.z=0.0300f; + image->chromaticity.green_primary.x=0.3000f; + image->chromaticity.green_primary.y=0.6000f; + image->chromaticity.green_primary.z=0.1000f; + image->chromaticity.blue_primary.x=0.1500f; + image->chromaticity.blue_primary.y=0.0600f; + image->chromaticity.blue_primary.z=0.7900f; + image->chromaticity.white_point.x=0.3127f; + image->chromaticity.white_point.y=0.3290f; + image->chromaticity.white_point.z=0.3583f; + } return(SyncImagePixelCache(image,exception)); } @@ -1299,10 +1319,11 @@ MagickExport MagickBooleanType TransformImageColorspace(Image *image, /* Convert the reference image from an alternate colorspace to sRGB. */ - if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace)) + if (IssRGBColorspace(colorspace) != MagickFalse) return(TransformsRGBImage(image,colorspace,exception)); status=MagickTrue; - if (image->colorspace == RGBColorspace) + if ((IsRGBColorspace(image->colorspace) != MagickFalse) || + (IsGrayColorspace(image->colorspace) != MagickFalse)) status=TransformsRGBImage(image,sRGBColorspace,exception); if (status == MagickFalse) return(status); diff --git a/MagickCore/image.c b/MagickCore/image.c index f02b7d6af..fdb9edcee 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -1303,7 +1303,7 @@ MagickExport Image *GetImageMask(const Image *image,ExceptionInfo *exception) if (mask_image == (Image *) NULL) return((Image *) NULL); status=MagickTrue; - mask_image->colorspace=GRAYColorspace; + SetImageColorspace(mask_image,GRAYColorspace,exception); mask_image->mask=MagickFalse; image_view=AcquireVirtualCacheView(image,exception); mask_view=AcquireAuthenticCacheView(mask_image,exception); diff --git a/MagickCore/paint.c b/MagickCore/paint.c index cf0299dca..05695c996 100644 --- a/MagickCore/paint.c +++ b/MagickCore/paint.c @@ -183,7 +183,7 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image, exception); if (floodplane_image == (Image *) NULL) return(MagickFalse); - floodplane_image->colorspace=GRAYColorspace; + SetImageColorspace(floodplane_image,GRAYColorspace,exception); (void) EvaluateImage(floodplane_image,SetEvaluateOperator,0.0,exception); segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize, sizeof(*segment_stack)); diff --git a/coders/art.c b/coders/art.c index 52b8d7be1..c6f037ddc 100644 --- a/coders/art.c +++ b/coders/art.c @@ -132,7 +132,7 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) image=DestroyImageList(image); return((Image *) NULL); } - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); image->depth=1; image->endian=MSBEndian; (void) ReadBlobLSBShort(image); diff --git a/coders/bgr.c b/coders/bgr.c index 9864e71cf..62a019c4d 100644 --- a/coders/bgr.c +++ b/coders/bgr.c @@ -141,7 +141,7 @@ static Image *ReadBGRImage(const ImageInfo *image_info, image=AcquireImage(image_info,exception); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); if (image_info->interlace != PartitionInterlace) { status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); @@ -197,7 +197,7 @@ static Image *ReadBGRImage(const ImageInfo *image_info, if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); switch (image_info->interlace) { case NoInterlace: diff --git a/coders/cin.c b/coders/cin.c index b49e97e3b..58f258d10 100644 --- a/coders/cin.c +++ b/coders/cin.c @@ -744,7 +744,7 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); - image->colorspace=LogColorspace; + SetImageColorspace(image,LogColorspace,exception); (void) CloseBlob(image); return(GetFirstImageInList(image)); } diff --git a/coders/cmyk.c b/coders/cmyk.c index 583b93cea..f93498abe 100644 --- a/coders/cmyk.c +++ b/coders/cmyk.c @@ -140,7 +140,7 @@ static Image *ReadCMYKImage(const ImageInfo *image_info, image=AcquireImage(image_info,exception); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); if (image_info->interlace != PartitionInterlace) { status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); @@ -196,7 +196,7 @@ static Image *ReadCMYKImage(const ImageInfo *image_info, if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); switch (image_info->interlace) { case NoInterlace: diff --git a/coders/dpx.c b/coders/dpx.c index 0738159d0..8190e048a 100644 --- a/coders/dpx.c +++ b/coders/dpx.c @@ -598,6 +598,7 @@ static Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Read DPX file header. */ + SetImageColorspace(image,RGBColorspace,exception); offset=0; count=ReadBlob(image,4,(unsigned char *) magick); offset+=count; @@ -1046,21 +1047,21 @@ static Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception) case CbYACrYA4224ComponentType: case CbYCr444ComponentType: { - image->colorspace=Rec709YCbCrColorspace; + SetImageColorspace(image,Rec709YCbCrColorspace,exception); break; } case LumaComponentType: { - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); break; } default: { - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); if (dpx.image.image_element[0].transfer == LogarithmicColorimetric) - image->colorspace=LogColorspace; + SetImageColorspace(image,LogColorspace,exception); if (dpx.image.image_element[0].transfer == PrintingDensityColorimetric) - image->colorspace=LogColorspace; + SetImageColorspace(image,LogColorspace,exception); break; } } diff --git a/coders/exr.c b/coders/exr.c index cec60d0ec..7e61d8936 100644 --- a/coders/exr.c +++ b/coders/exr.c @@ -200,7 +200,7 @@ static Image *ReadEXRImage(const ImageInfo *image_info,ExceptionInfo *exception) image->columns=max_x-min_x+1UL; image->rows=max_y-min_y+1UL; image->matte=MagickTrue; - image->colorspace=RGBColorspace; + SetImageColorspace(image,RGBColorspace,exception); image->gamma=1.0; if (image_info->ping != MagickFalse) { diff --git a/coders/fits.c b/coders/fits.c index 164286321..6aa2f15c6 100644 --- a/coders/fits.c +++ b/coders/fits.c @@ -416,7 +416,7 @@ static Image *ReadFITSImage(const ImageInfo *image_info, fits_info.bits_per_pixel; image->endian=fits_info.endian; image->scene=(size_t) scene; - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; diff --git a/coders/gray.c b/coders/gray.c index 09b899995..207230997 100644 --- a/coders/gray.c +++ b/coders/gray.c @@ -150,7 +150,7 @@ static Image *ReadGRAYImage(const ImageInfo *image_info, /* Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]). */ - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse, exception); (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod, diff --git a/coders/hdr.c b/coders/hdr.c index dec816777..ea6fa0954 100644 --- a/coders/hdr.c +++ b/coders/hdr.c @@ -373,7 +373,7 @@ static Image *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize"); if (LocaleCompare(format,"32-bit_rle_xyze") == 0) - image->colorspace=XYZColorspace; + SetImageColorspace(image,XYZColorspace,exception); image->compression=(image->columns < 8) || (image->columns > 0x7ffff) ? NoCompression : RLECompression; if (image_info->ping != MagickFalse) diff --git a/coders/ipl.c b/coders/ipl.c index 7a8559b2b..ecf7819d5 100644 --- a/coders/ipl.c +++ b/coders/ipl.c @@ -246,7 +246,7 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) if((ipl_info.width == 0UL) || (ipl_info.height == 0UL)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); ipl_info.colors=ReadBlobLong(image); - if(ipl_info.colors == 3){ image->colorspace=sRGBColorspace;} + if(ipl_info.colors == 3){ SetImageColorspace(image,sRGBColorspace,exception);} else { image->colorspace = GRAYColorspace; } ipl_info.z=ReadBlobLong(image); ipl_info.time=ReadBlobLong(image); diff --git a/coders/jp2.c b/coders/jp2.c index 17f198019..ddd231ff9 100644 --- a/coders/jp2.c +++ b/coders/jp2.c @@ -454,7 +454,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) image->matte=MagickTrue; number_components++; } - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); break; } default: @@ -468,7 +468,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) image->rows=jas_image_height(jp2_image); image->compression=JPEG2000Compression; if (number_components == 1) - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); for (i=0; i < (ssize_t) number_components; i++) { size_t diff --git a/coders/jpeg.c b/coders/jpeg.c index 31f13c645..75f2f11c9 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1069,12 +1069,12 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, jpeg_info.out_color_space=JCS_YCbCr; if (IsITUFaxImage(image) != MagickFalse) { - image->colorspace=LabColorspace; + SetImageColorspace(image,LabColorspace,exception); jpeg_info.out_color_space=JCS_YCbCr; } else if (jpeg_info.out_color_space == JCS_CMYK) - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); /* Set image resolution. */ @@ -1196,9 +1196,9 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, image->rows=jpeg_info.output_height; image->depth=(size_t) jpeg_info.data_precision; if (jpeg_info.out_color_space == JCS_YCbCr) - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); if (jpeg_info.out_color_space == JCS_CMYK) - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); option=GetImageOption(image_info,"jpeg:colors"); if (option != (const char *) NULL) if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) diff --git a/coders/mat.c b/coders/mat.c index 244b8d6c7..06ecfe668 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -783,7 +783,7 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0)) { image->type=GrayscaleType; - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); } switch (CellType) diff --git a/coders/pcd.c b/coders/pcd.c index 54b2f5d91..964e5c5e1 100644 --- a/coders/pcd.c +++ b/coders/pcd.c @@ -681,7 +681,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception) } image->colorspace=YCCColorspace; if (LocaleCompare(image_info->magick,"PCDS") == 0) - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); if (j < (ssize_t) number_images) { /* @@ -835,7 +835,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception) image->gamma=1.000f/2.200f; image->colorspace=YCCColorspace; if (LocaleCompare(image_info->magick,"PCDS") == 0) - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); return(GetFirstImageInList(image)); } diff --git a/coders/png.c b/coders/png.c index 3067a3e2d..2ebc89e44 100644 --- a/coders/png.c +++ b/coders/png.c @@ -2724,7 +2724,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, image->rows=ping_height; if (((int) ping_color_type == PNG_COLOR_TYPE_GRAY) || ((int) ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); if (((int) ping_color_type == PNG_COLOR_TYPE_PALETTE) || ((int) ping_color_type == PNG_COLOR_TYPE_GRAY)) { diff --git a/coders/pnm.c b/coders/pnm.c index fe9b47b55..2677656f2 100644 --- a/coders/pnm.c +++ b/coders/pnm.c @@ -380,12 +380,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) } if (LocaleCompare(value,"GRAYSCALE") == 0) { - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); quantum_type=GrayQuantum; } if (LocaleCompare(value,"GRAYSCALE_ALPHA") == 0) { - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); image->matte=MagickTrue; quantum_type=GrayAlphaQuantum; } @@ -397,12 +397,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) if (LocaleCompare(value,"CMYK") == 0) { quantum_type=CMYKQuantum; - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); } if (LocaleCompare(value,"CMYK_ALPHA") == 0) { quantum_type=CMYKAQuantum; - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); image->matte=MagickTrue; } } @@ -431,7 +431,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Convert PBM image to pixel packets. */ - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); for (y=0; y < (ssize_t) image->rows; y++) { register ssize_t @@ -470,7 +470,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Convert PGM image to pixel packets. */ - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); scale=(Quantum *) NULL; if (max_value != (1U*QuantumRange)) { @@ -589,7 +589,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Convert PBM raw image to pixel packets. */ - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); quantum_type=GrayQuantum; if (image->storage_class == PseudoClass) quantum_type=IndexQuantum; @@ -664,7 +664,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Convert PGM raw image to pixel packets. */ - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); range=GetQuantumRange(image->depth); quantum_type=GrayQuantum; extent=(image->depth <= 8 ? 1 : 2)*image->columns; @@ -1165,7 +1165,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) Convert PFM raster image to pixel packets. */ if (format == 'f') - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); quantum_type=format == 'f' ? GrayQuantum : RGBQuantum; image->endian=quantum_scale < 0.0 ? LSBEndian : MSBEndian; image->depth=32; diff --git a/coders/psd.c b/coders/psd.c index 4f66b88cf..03060457b 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -834,12 +834,12 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) } image->matte=psd_info.channels >= 4 ? MagickTrue : MagickFalse; if (psd_info.mode == LabMode) - image->colorspace=LabColorspace; + SetImageColorspace(image,LabColorspace,exception); psd_info.color_channels=3; if (psd_info.mode == CMYKMode) { psd_info.color_channels=4; - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); image->matte=psd_info.channels >= 5 ? MagickTrue : MagickFalse; } if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || @@ -852,7 +852,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Image colormap allocated"); - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); } image->matte=MagickFalse; /* @@ -1235,11 +1235,11 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) if (layer_info[i].visible == MagickFalse) layer_info[i].image->compose=NoCompositeOp; if (psd_info.mode == CMYKMode) - layer_info[i].image->colorspace=CMYKColorspace; + SetImageColorspace(layer_info[i].image,CMYKColorspace,exception); if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || (psd_info.mode == DuotoneMode)) - layer_info[i].image->colorspace=GRAYColorspace; + SetImageColorspace(layer_info[i].image,GRAYColorspace,exception); for (j=0; j < (ssize_t) layer_info[i].channels; j++) if (layer_info[i].channel_info[j].type == -1) layer_info[i].image->matte=MagickTrue; diff --git a/coders/rgb.c b/coders/rgb.c index cc731294e..9241357e6 100644 --- a/coders/rgb.c +++ b/coders/rgb.c @@ -140,7 +140,7 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception) image=AcquireImage(image_info,exception); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); if (image_info->interlace != PartitionInterlace) { status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); @@ -202,7 +202,7 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); switch (image_info->interlace) { case NoInterlace: diff --git a/coders/sct.c b/coders/sct.c index e4120626b..2294d881c 100644 --- a/coders/sct.c +++ b/coders/sct.c @@ -213,7 +213,7 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception) count=ReadBlob(image,200,buffer); count=ReadBlob(image,768,buffer); if (separations_mask == 0x0f) - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); image->resolution.x=1.0*image->columns/width; image->resolution.y=1.0*image->rows/height; if (image_info->ping != MagickFalse) diff --git a/coders/tiff.c b/coders/tiff.c index 8f96fb531..f3efe250d 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1012,11 +1012,11 @@ static Image *ReadTIFFImage(const ImageInfo *image_info, image->endian=LSBEndian; if ((photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_MINISWHITE)) - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); if (photometric == PHOTOMETRIC_SEPARATED) - image->colorspace=CMYKColorspace; + SetImageColorspace(image,CMYKColorspace,exception); if (photometric == PHOTOMETRIC_CIELAB) - image->colorspace=LabColorspace; + SetImageColorspace(image,LabColorspace,exception); (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units); diff --git a/coders/uyvy.c b/coders/uyvy.c index ce0d7c44b..83a936314 100644 --- a/coders/uyvy.c +++ b/coders/uyvy.c @@ -175,7 +175,7 @@ static Image *ReadUYVYImage(const ImageInfo *image_info, if (status == MagickFalse) break; } - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); diff --git a/coders/xcf.c b/coders/xcf.c index e78ca4b5c..3d699978c 100644 --- a/coders/xcf.c +++ b/coders/xcf.c @@ -1055,10 +1055,10 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception) image->compression=NoCompression; image->depth=8; if (image_type == GIMP_RGB) - image->colorspace=sRGBColorspace; + SetImageColorspace(image,sRGBColorspace,exception); else if (image_type == GIMP_GRAY) - image->colorspace=GRAYColorspace; + SetImageColorspace(image,GRAYColorspace,exception); else if (image_type == GIMP_INDEXED) ThrowReaderException(CoderError,"ColormapTypeNotSupported"); diff --git a/coders/ycbcr.c b/coders/ycbcr.c index a3f063b61..a983d0eb1 100644 --- a/coders/ycbcr.c +++ b/coders/ycbcr.c @@ -147,7 +147,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info, image=AcquireImage(image_info,exception); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); if (image_info->interlace != PartitionInterlace) { status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); @@ -203,7 +203,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info, if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); switch (image_info->interlace) { case NoInterlace: diff --git a/coders/yuv.c b/coders/yuv.c index 418824e08..45abc5b10 100644 --- a/coders/yuv.c +++ b/coders/yuv.c @@ -414,7 +414,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception) break; } resize_image=DestroyImage(resize_image); - image->colorspace=YCbCrColorspace; + SetImageColorspace(image,YCbCrColorspace,exception); if (interlace == PartitionInterlace) (void) CopyMagickString(image->filename,image_info->filename, MaxTextExtent); diff --git a/tests/validate.c b/tests/validate.c index ae4a1919a..c03c315f1 100644 --- a/tests/validate.c +++ b/tests/validate.c @@ -935,7 +935,7 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info, continue; } if (LocaleNCompare(reference_map[i],"cmy",3) == 0) - reference_image->colorspace=CMYKColorspace; + SetImageColorspace(reference_image,CMYKColorspace,exception); length=strlen(reference_map[i])*reference_image->columns* reference_image->rows*reference_storage[j].quantum; pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels)); -- 2.40.0