separate_image=DestroyImage(separate_image);
return((Image *) NULL);
}
- separate_image->colorspace=GRAYColorspace;
+ SetImageColorspace(separate_image,GRAYColorspace,exception);
separate_image->matte=MagickFalse;
/*
Separate image.
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);
}
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));
}
\f
/*
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);
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);
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));
image=DestroyImageList(image);
return((Image *) NULL);
}
- image->colorspace=GRAYColorspace;
+ SetImageColorspace(image,GRAYColorspace,exception);
image->depth=1;
image->endian=MSBEndian;
(void) ReadBlobLSBShort(image);
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);
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:
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
- image->colorspace=LogColorspace;
+ SetImageColorspace(image,LogColorspace,exception);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
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);
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:
/*
Read DPX file header.
*/
+ SetImageColorspace(image,RGBColorspace,exception);
offset=0;
count=ReadBlob(image,4,(unsigned char *) magick);
offset+=count;
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;
}
}
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)
{
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;
/*
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,
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)
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);
image->matte=MagickTrue;
number_components++;
}
- image->colorspace=YCbCrColorspace;
+ SetImageColorspace(image,YCbCrColorspace,exception);
break;
}
default:
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
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.
*/
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)
((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))
{
image->type=GrayscaleType;
- image->colorspace=GRAYColorspace;
+ SetImageColorspace(image,GRAYColorspace,exception);
}
switch (CellType)
}
image->colorspace=YCCColorspace;
if (LocaleCompare(image_info->magick,"PCDS") == 0)
- image->colorspace=sRGBColorspace;
+ SetImageColorspace(image,sRGBColorspace,exception);
if (j < (ssize_t) number_images)
{
/*
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));
}
\f
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))
{
}
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;
}
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;
}
}
/*
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
/*
Convert PGM image to pixel packets.
*/
- image->colorspace=GRAYColorspace;
+ SetImageColorspace(image,GRAYColorspace,exception);
scale=(Quantum *) NULL;
if (max_value != (1U*QuantumRange))
{
/*
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;
/*
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;
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;
}
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) ||
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Image colormap allocated");
- image->colorspace=GRAYColorspace;
+ SetImageColorspace(image,GRAYColorspace,exception);
}
image->matte=MagickFalse;
/*
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;
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);
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:
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)
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);
if (status == MagickFalse)
break;
}
- image->colorspace=YCbCrColorspace;
+ SetImageColorspace(image,YCbCrColorspace,exception);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
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");
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);
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:
break;
}
resize_image=DestroyImage(resize_image);
- image->colorspace=YCbCrColorspace;
+ SetImageColorspace(image,YCbCrColorspace,exception);
if (interlace == PartitionInterlace)
(void) CopyMagickString(image->filename,image_info->filename,
MaxTextExtent);
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));