% 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, %
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[MagickPathExtent],
geometry[MagickPathExtent],
- *p;
+ *p,
+ text[MagickPathExtent];
DrawInfo
*draw_info;
Image
+ *image,
*texture;
MagickBooleanType
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
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.
*/
(void) SetImageBackgroundColor(image,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
- (void) FormatLocaleString(geometry,MagickPathExtent,"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,MagickPathExtent,"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,MagickPathExtent);
if (*draw_info->text != '\0')
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;
long
- type,
x_offset,
- y,
y_offset;
PixelInfo
*q;
ssize_t
- count;
+ count,
+ type,
+ y;
unsigned long
depth,
(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;
SetPixelViaPixelInfo(image,&pixel,q);
entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
entry=AcquireMagickInfo("TXT","TEXT","Text");
- entry->decoder=(DecodeImageHandler *) ReadTXTImage;
- entry->encoder=(EncodeImageHandler *) WriteTXTImage;
+ entry->decoder=(DecodeImageHandler *) ReadTEXTImage;
+ entry->format_type=ImplicitFormatType;
entry->flags|=CoderRawSupportFlag;
entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
ComplianceType
compliance;
+ const char
+ *value;
+
(void) CopyMagickString(colorspace,CommandOptionToMnemonic(
MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent);
LocaleLower(colorspace);
if (image->alpha_trait != UndefinedPixelTrait)
(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)
{
+ 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,MagickPathExtent,"%.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,MagickPathExtent,"%.20g,%.20g: ",(double)
- x,(double) y);
+ (void) FormatLocaleString(buffer,MagickPathExtent,"%.20g,%.20g: ",
+ (double) x,(double) y);
(void) WriteBlobString(image,buffer);
(void) CopyMagickString(tuple,"(",MagickPathExtent);
if (pixel.colorspace == GRAYColorspace)
- ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,
- tuple);
+ ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple);
else
{
ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple);