% July 1992 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 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 %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
#define MagickID "# ImageMagick pixel enumeration:"
char
- colorspace[MaxTextExtent];
+ colorspace[MagickPathExtent];
ssize_t
count;
return(MagickFalse);
if (LocaleNCompare((const char *) magick,MagickID,strlen(MagickID)) != 0)
return(MagickFalse);
- count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%s",&columns,
+ count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%32s",&columns,
&rows,&depth,colorspace);
if (count != 4)
return(MagickFalse);
% o exception: return any errors or warnings in this structure.
%
*/
-static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
- char *text,ExceptionInfo *exception)
+static Image *ReadTEXTImage(const ImageInfo *image_info,
+ ExceptionInfo *exception)
{
char
- filename[MaxTextExtent],
- geometry[MaxTextExtent],
- *p;
+ filename[MagickPathExtent],
+ geometry[MagickPathExtent],
+ *p,
+ text[MagickPathExtent];
DrawInfo
*draw_info;
Image
+ *image,
*texture;
MagickBooleanType
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
+ image=AcquireImage(image_info,exception);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ (void) ResetMagickMemory(text,0,sizeof(text));
+ (void) ReadBlobString(image,text);
/*
Set the page geometry.
*/
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(read_info->filename,image_info->texture,
- MaxTextExtent);
+ MagickPathExtent);
texture=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
}
(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,
- (long) page.y);
+ (void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
+ image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
status=GetTypeMetrics(image,draw_info,&metrics,exception);
if (status == MagickFalse)
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
- (void) FormatLocaleString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x,
- (long) page.y);
+ (void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
+ image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
- (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
+ (void) CopyMagickString(filename,image_info->filename,MagickPathExtent);
if (*draw_info->text != '\0')
*draw_info->text='\0';
p=text;
offset+=(ssize_t) (metrics.ascent-metrics.descent);
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,LoadImageTag,offset,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset,
+ image->rows);
if (status == MagickFalse)
break;
}
image->next->columns=image->columns;
image->next->rows=image->rows;
image=SyncNextImageInList(image);
- (void) CopyMagickString(image->filename,filename,MaxTextExtent);
+ (void) CopyMagickString(image->filename,filename,MagickPathExtent);
(void) SetImageBackgroundColor(image,exception);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
- colorspace[MaxTextExtent],
- text[MaxTextExtent];
+ colorspace[MagickPathExtent],
+ text[MagickPathExtent];
Image
*image;
long
- type,
x_offset,
- y,
y_offset;
PixelInfo
*q;
ssize_t
- count;
+ count,
+ type,
+ y;
unsigned long
depth,
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
(void) ResetMagickMemory(text,0,sizeof(text));
(void) ReadBlobString(image,text);
if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
- return(ReadTEXTImage(image_info,image,text,exception));
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
do
{
width=0;
height=0;
max_value=0;
*colorspace='\0';
- count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&width,&height,&max_value,
+ count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%32s",&width,&height,&max_value,
colorspace);
if ((count != 4) || (width == 0) || (height == 0) || (max_value == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
image->columns=width;
image->rows=height;
+ if ((max_value == 0) || (max_value > 4294967295UL))
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
image->depth=depth;
status=SetImageExtent(image,image->columns,image->rows,exception);
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);
+ pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (red+0.5),
+ range);
+ pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (green+0.5),
+ range);
+ pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (blue+0.5),
+ range);
+ pixel.black=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (black+0.5),
+ range);
+ pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (alpha+0.5),
+ range);
+ q=GetAuthenticPixels(image,(ssize_t) x_offset,(ssize_t) y_offset,1,1,
+ exception);
if (q == (Quantum *) NULL)
continue;
- SetPixelInfoPixel(image,&pixel,q);
+ SetPixelViaPixelInfo(image,&pixel,q);
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
MagickInfo
*entry;
- entry=SetMagickInfo("SPARSE-COLOR");
+ entry=AcquireMagickInfo("TXT","SPARSE-COLOR","Sparse Color");
entry->encoder=(EncodeImageHandler *) WriteTXTImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Sparse Color");
- entry->module=ConstantString("TXT");
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("TEXT");
- entry->decoder=(DecodeImageHandler *) ReadTXTImage;
- entry->encoder=(EncodeImageHandler *) WriteTXTImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Text");
- entry->module=ConstantString("TXT");
+ entry=AcquireMagickInfo("TXT","TEXT","Text");
+ entry->decoder=(DecodeImageHandler *) ReadTEXTImage;
+ entry->format_type=ImplicitFormatType;
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("TXT");
+ entry=AcquireMagickInfo("TXT","TXT","Text");
entry->decoder=(DecodeImageHandler *) ReadTXTImage;
entry->encoder=(EncodeImageHandler *) WriteTXTImage;
- entry->description=ConstantString("Text");
entry->magick=(IsImageFormatHandler *) IsTXT;
- entry->module=ConstantString("TXT");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ExceptionInfo *exception)
{
char
- buffer[MaxTextExtent],
- colorspace[MaxTextExtent],
- tuple[MaxTextExtent];
+ buffer[MagickPathExtent],
+ colorspace[MagickPathExtent],
+ tuple[MagickPathExtent];
MagickBooleanType
status;
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBlobMode,exception);
ComplianceType
compliance;
+ const char
+ *value;
+
(void) CopyMagickString(colorspace,CommandOptionToMnemonic(
- MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent);
+ MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent);
LocaleLower(colorspace);
image->depth=GetImageQuantumDepth(image,MagickTrue);
if (image->alpha_trait != UndefinedPixelTrait)
- (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
+ (void) ConcatenateMagickString(colorspace,"a",MagickPathExtent);
compliance=NoCompliance;
+ value=GetImageOption(image_info,"txt:compliance");
+ if (value != (char *) NULL)
+ compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions,
+ MagickFalse,value);
if (LocaleCompare(image_info->magick,"SPARSE-COLOR") != 0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ size_t
+ depth;
+
+ depth=compliance == SVGCompliance ? image->depth :
+ MAGICKCORE_QUANTUM_DEPTH;
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double)
image->columns,(double) image->rows,(double) ((MagickOffsetType)
- GetQuantumRange(image->depth)),colorspace);
+ GetQuantumRange(depth)),colorspace);
(void) WriteBlobString(image,buffer);
- compliance=SVGCompliance;
}
GetPixelInfo(image,&pixel);
for (y=0; y < (ssize_t) image->rows; y++)
if (GetPixelAlpha(image,p) == (Quantum) OpaqueAlpha)
{
GetColorTuple(&pixel,MagickFalse,tuple);
- (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g,",
- (double) x,(double) y);
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "%.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) FormatLocaleString(buffer,MagickPathExtent,"%.20g,%.20g: ",
+ (double) x,(double) y);
(void) WriteBlobString(image,buffer);
- (void) CopyMagickString(tuple,"(",MaxTextExtent);
+ (void) CopyMagickString(tuple,"(",MagickPathExtent);
if (pixel.colorspace == GRAYColorspace)
- ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,
- tuple);
+ ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple);
else
{
ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple);
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
ConcatenateColorComponent(&pixel,GreenPixelChannel,compliance,
tuple);
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
ConcatenateColorComponent(&pixel,BluePixelChannel,compliance,tuple);
}
if (pixel.colorspace == CMYKColorspace)
{
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
ConcatenateColorComponent(&pixel,BlackPixelChannel,compliance,
tuple);
}
if (pixel.alpha_trait != UndefinedPixelTrait)
{
- (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
+ (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
ConcatenateColorComponent(&pixel,AlphaPixelChannel,compliance,
tuple);
}
- (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
+ (void) ConcatenateMagickString(tuple,")",MagickPathExtent);
(void) WriteBlobString(image,tuple);
(void) WriteBlobString(image," ");
GetColorTuple(&pixel,MagickTrue,tuple);
- (void) FormatLocaleString(buffer,MaxTextExtent,"%s",tuple);
+ (void) FormatLocaleString(buffer,MagickPathExtent,"%s",tuple);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image," ");
(void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception);