% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
- if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
+ if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
{
GeometryInfo
geometry_info;
flags;
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
- image->y_resolution=image->x_resolution;
+ image->resolution.y=image->resolution.x;
}
page.width=612;
page.height=792;
/*
Initialize Image structure.
*/
- image->columns=(size_t) floor((((double) page.width*image->x_resolution)/
+ image->columns=(size_t) floor((((double) page.width*image->resolution.x)/
delta.x)+0.5);
- image->rows=(size_t) floor((((double) page.height*image->y_resolution)/
+ image->rows=(size_t) floor((((double) page.height*image->resolution.y)/
delta.y)+0.5);
image->page.x=0;
image->page.y=0;
/*
Annotate the text image.
*/
- (void) SetImageBackgroundColor(image);
+ (void) SetImageBackgroundColor(image,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
(void) FormatLocaleString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x,
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
- (void) TextureImage(image,texture);
+ (void) TextureImage(image,texture,exception);
(void) SetImageProgressMonitor(image,progress_monitor,
image->client_data);
}
image->next->rows=image->rows;
image=SyncNextImageInList(image);
(void) CopyMagickString(image->filename,filename,MaxTextExtent);
- (void) SetImageBackgroundColor(image);
+ (void) SetImageBackgroundColor(image,exception);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
- (void) TextureImage(image,texture);
+ (void) TextureImage(image,texture,exception);
(void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
}
(void) AnnotateImage(image,draw_info,exception);
image->depth=depth;
LocaleLower(colorspace);
i=(ssize_t) strlen(colorspace)-1;
- image->matte=MagickFalse;
+ image->alpha_trait=UndefinedPixelTrait;
if ((i > 0) && (colorspace[i] == 'a'))
{
colorspace[i]='\0';
- image->matte=MagickTrue;
+ image->alpha_trait=BlendPixelTrait;
}
type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace);
if (type < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- image->colorspace=(ColorspaceType) type;
- (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
- (void) SetImageBackgroundColor(image);
+ (void) SetImageBackgroundColor(image,exception);
+ (void) SetImageColorspace(image,(ColorspaceType) type,exception);
+ GetPixelInfo(image,&pixel);
range=GetQuantumRange(image->depth);
for (y=0; y < (ssize_t) image->rows; y++)
{
+ double
+ alpha,
+ black,
+ blue,
+ green,
+ red;
+
for (x=0; x < (ssize_t) image->columns; x++)
{
if (ReadBlobString(image,text) == (char *) NULL)
break;
- if (image->colorspace == CMYKColorspace)
+ switch (image->colorspace)
+ {
+ case GRAYColorspace:
{
- if (image->matte != MagickFalse)
- count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf,%lf",
- &x_offset,&y_offset,&pixel.red,&pixel.green,&pixel.blue,
- &pixel.black,&pixel.alpha);
- else
- count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf",&x_offset,
- &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.black);
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf",&x_offset,
+ &y_offset,&red,&alpha);
+ green=red;
+ blue=red;
+ break;
+ }
+ count=(ssize_t) sscanf(text,"%ld,%ld: (%lf",&x_offset,&y_offset,
+ &red);
+ green=red;
+ blue=red;
+ break;
}
- else
- if (image->matte != MagickFalse)
+ case CMYKColorspace:
+ {
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf,%lf",
+ &x_offset,&y_offset,&red,&green,&blue,&black,&alpha);
+ break;
+ }
count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf",&x_offset,
- &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.alpha);
- else
+ &y_offset,&red,&green,&blue,&black);
+ break;
+ }
+ default:
+ {
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf",
+ &x_offset,&y_offset,&red,&green,&blue,&alpha);
+ break;
+ }
count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf",&x_offset,
- &y_offset,&pixel.red,&pixel.green,&pixel.blue);
- if (count < 5)
- continue;
+ &y_offset,&red,&green,&blue);
+ break;
+ }
+ }
+ if (image->colorspace == LabColorspace)
+ {
+ green+=(range+1)/2.0;
+ blue+=(range+1)/2.0;
+ }
+ pixel.red=ScaleAnyToQuantum((QuantumAny) (red+0.5),range);
+ pixel.green=ScaleAnyToQuantum((QuantumAny) (green+0.5),range);
+ pixel.blue=ScaleAnyToQuantum((QuantumAny) (blue+0.5),range);
+ pixel.black=ScaleAnyToQuantum((QuantumAny) (black+0.5),range);
+ pixel.alpha=ScaleAnyToQuantum((QuantumAny) (alpha+0.5),range);
q=GetAuthenticPixels(image,x_offset,y_offset,1,1,exception);
if (q == (Quantum *) NULL)
continue;
- SetPixelRed(image,ScaleAnyToQuantum(pixel.red,range),q);
- SetPixelGreen(image,ScaleAnyToQuantum(pixel.green,range),q);
- SetPixelBlue(image,ScaleAnyToQuantum(pixel.blue,range),q);
- if (image->colorspace == CMYKColorspace)
- SetPixelBlack(image,ScaleAnyToQuantum(pixel.black,range),q);
- if (image->matte != MagickFalse)
- SetPixelAlpha(image,ScaleAnyToQuantum(pixel.alpha,range),q);
+ SetPixelInfoPixel(image,&pixel,q);
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
colorspace[MaxTextExtent],
tuple[MaxTextExtent];
+ const char
+ *option;
+
MagickBooleanType
+ sparse_color,
status;
MagickOffsetType
status=OpenBlob(image_info,image,WriteBlobMode,exception);
if (status == MagickFalse)
return(status);
+ option=GetImageOption(image_info,"txt:sparse-color");
+ sparse_color=IsStringTrue(option);
scene=0;
do
{
MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent);
LocaleLower(colorspace);
image->depth=GetImageQuantumDepth(image,MagickTrue);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
(void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
(void) FormatLocaleString(buffer,MaxTextExtent,
"# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
+ GetPixelInfoPixel(image,p,&pixel);
+ if (pixel.colorspace == LabColorspace)
+ {
+ pixel.green-=(QuantumRange+1)/2.0;
+ pixel.blue-=(QuantumRange+1)/2.0;
+ }
+ if (sparse_color != MagickFalse)
+ {
+ /*
+ Sparse-color format.
+ */
+ if (GetPixelAlpha(image,p) == (Quantum) OpaqueAlpha)
+ {
+ (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
+ exception);
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g ",
+ (double) x,(double) y);
+ (void) WriteBlobString(image,buffer);
+ (void) WriteBlobString(image,tuple);
+ (void) WriteBlobString(image," ");
+ }
+ p+=GetPixelChannels(image);
+ continue;
+ }
(void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g: ",(double)
x,(double) y);
(void) WriteBlobString(image,buffer);
- SetPixelInfo(image,p,&pixel);
(void) CopyMagickString(tuple,"(",MaxTextExtent);
- ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
- tuple);
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
- ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
- tuple);
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
- ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
- tuple);
+ if (pixel.colorspace == GRAYColorspace)
+ ConcatenateColorComponent(&pixel,GrayPixelChannel,X11Compliance,
+ tuple);
+ else
+ {
+ ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
+ tuple);
+ (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
+ tuple);
+ (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
+ tuple);
+ }
if (pixel.colorspace == CMYKColorspace)
{
(void) ConcatenateMagickString(tuple,",",MaxTextExtent);
ConcatenateColorComponent(&pixel,BlackPixelChannel,X11Compliance,
tuple);
}
- if (pixel.matte != MagickFalse)
+ if (pixel.alpha_trait == BlendPixelTrait)
{
(void) ConcatenateMagickString(tuple,",",MaxTextExtent);
ConcatenateColorComponent(&pixel,AlphaPixelChannel,X11Compliance,
(void) FormatLocaleString(buffer,MaxTextExtent,"%s",tuple);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image," ");
- (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,exception);
+ (void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception);
(void) WriteBlobString(image,tuple);
(void) WriteBlobString(image,"\n");
p+=GetPixelChannels(image);