% March 2000 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 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 %
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/geometry.h"
-#include "MagickCore/hashmap.h"
#include "MagickCore/image.h"
#include "MagickCore/image-private.h"
+#include "MagickCore/linked-list.h"
#include "MagickCore/list.h"
#include "MagickCore/magick.h"
#include "MagickCore/memory_.h"
#include "MagickCore/profile.h"
#include "MagickCore/property.h"
#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
#include "MagickCore/static.h"
#include "MagickCore/statistic.h"
#include "MagickCore/string_.h"
static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
- cache_filename[MaxTextExtent],
- id[MaxTextExtent],
- keyword[MaxTextExtent],
+ cache_filename[MagickPathExtent],
+ id[MagickPathExtent],
+ keyword[MagickPathExtent],
*options;
const unsigned char
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) CopyMagickString(cache_filename,image->filename,MaxTextExtent);
+ (void) CopyMagickString(cache_filename,image->filename,MagickPathExtent);
AppendImageFormat("cache",cache_filename);
c=ReadBlobByte(image);
if (c == EOF)
Decode image header; header terminates one character beyond a ':'.
*/
profiles=(LinkedListInfo *) NULL;
- length=MaxTextExtent;
+ length=MagickPathExtent;
options=AcquireString((char *) NULL);
signature=GetMagickSignature((const StringInfo *) NULL);
image->depth=8;
/*
Read comment-- any text between { }.
*/
- length=MaxTextExtent;
+ length=MagickPathExtent;
comment=AcquireString((char *) NULL);
for (p=comment; comment != (char *) NULL; p++)
{
*p='\0';
length<<=1;
comment=(char *) ResizeQuantumMemory(comment,length+
- MaxTextExtent,sizeof(*comment));
+ MagickPathExtent,sizeof(*comment));
if (comment == (char *) NULL)
break;
p=comment+strlen(comment);
/*
Get the keyword.
*/
- length=MaxTextExtent;
+ length=MagickPathExtent;
p=keyword;
do
{
if (c == (int) '=')
break;
- if ((size_t) (p-keyword) < (MaxTextExtent-1))
+ if ((size_t) (p-keyword) < (MagickPathExtent-1))
*p++=(char) c;
c=ReadBlobByte(image);
} while (c != EOF);
*p='\0';
length<<=1;
options=(char *) ResizeQuantumMemory(options,length+
- MaxTextExtent,sizeof(*options));
+ MagickPathExtent,sizeof(*options));
if (options == (char *) NULL)
break;
p=options+strlen(options);
{
if (LocaleCompare(keyword,"id") == 0)
{
- (void) CopyMagickString(id,options,MaxTextExtent);
+ (void) CopyMagickString(id,options,MagickPathExtent);
break;
}
if (LocaleCompare(keyword,"iterations") == 0)
signature=(unsigned int) StringToUnsignedLong(options);
break;
}
- if (LocaleCompare(keyword,"matte-color") == 0)
+ if (LocaleCompare(keyword,"mattecolor") == 0)
{
(void) QueryColorCompliance(options,AllCompliance,
&image->matte_color,exception);
(void) SetImageProperty(image,keyword,options,exception);
break;
}
+ case 'n':
+ case 'N':
+ {
+ if (LocaleCompare(keyword,"number-channels") == 0)
+ {
+ image->number_channels=StringToUnsignedLong(options);
+ break;
+ }
+ if (LocaleCompare(keyword,"number-meta-channels") == 0)
+ {
+ image->number_meta_channels=StringToUnsignedLong(options);
+ break;
+ }
+ break;
+ }
case 'o':
case 'O':
{
/*
Image directory.
*/
- length=MaxTextExtent;
+ length=MagickPathExtent;
image->directory=AcquireString((char *) NULL);
p=image->directory;
do
{
*p='\0';
- if ((strlen(image->directory)+MaxTextExtent) >= length)
+ if ((strlen(image->directory)+MagickPathExtent) >= length)
{
/*
Allocate more memory for the image directory.
*/
length<<=1;
image->directory=(char *) ResizeQuantumMemory(image->directory,
- length+MaxTextExtent,sizeof(*image->directory));
+ length+MagickPathExtent,sizeof(*image->directory));
if (image->directory == (char *) NULL)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
p=image->directory+strlen(image->directory);
/*
Create image colormap.
*/
- if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
+ if (AcquireImageColormap(image,image->colors) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (image->colors != 0)
{
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
- status=SetImageExtent(image,image->columns,image->rows,exception);
- if (status == MagickFalse)
- return(DestroyImageList(image));
+ if ((AcquireMagickResource(WidthResource,image->columns) == MagickFalse) ||
+ (AcquireMagickResource(HeightResource,image->rows) == MagickFalse))
+ ThrowReaderException(ImageError,"WidthOrHeightExceedsLimit");
/*
Attach persistent pixel cache.
*/
MagickInfo
*entry;
- entry=SetMagickInfo("CACHE");
- entry->description=ConstantString("Magick Persistent Cache image format");
- entry->module=ConstantString("CACHE");
+ entry=AcquireMagickInfo("MPC","CACHE",
+ "Magick Persistent Cache image format");
entry->flags|=CoderStealthFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("MPC");
+ entry=AcquireMagickInfo("MPC","MPC","Magick Persistent Cache image format");
entry->decoder=(DecodeImageHandler *) ReadMPCImage;
entry->encoder=(EncodeImageHandler *) WriteMPCImage;
entry->magick=(IsImageFormatHandler *) IsMPC;
- entry->description=ConstantString("Magick Persistent Cache image format");
- entry->module=ConstantString("MPC");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ExceptionInfo *exception)
{
char
- buffer[MaxTextExtent],
- cache_filename[MaxTextExtent];
+ buffer[MagickPathExtent],
+ cache_filename[MagickPathExtent];
const char
*property,
Open persistent cache.
*/
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);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- (void) CopyMagickString(cache_filename,image->filename,MaxTextExtent);
+ (void) CopyMagickString(cache_filename,image->filename,MagickPathExtent);
AppendImageFormat("cache",cache_filename);
scene=0;
offset=0;
(image->colors > (size_t) (GetQuantumRange(image->depth)+1)))
(void) SetImageStorageClass(image,DirectClass,exception);
(void) WriteBlobString(image,"id=MagickCache\n");
- (void) FormatLocaleString(buffer,MaxTextExtent,"magick-signature=%u\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"magick-signature=%u\n",
GetMagickSignature((const StringInfo *) NULL));
(void) WriteBlobString(image,buffer);
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"class=%s colors=%.20g alpha-trait=%s\n",CommandOptionToMnemonic(
MagickClassOptions,image->storage_class),(double) image->colors,
CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
image->alpha_trait));
(void) WriteBlobString(image,buffer);
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "number-channels=%.20g number-meta-channels=%.20g\n",
+ (double) image->number_channels,(double) image->number_meta_channels);
+ (void) WriteBlobString(image,buffer);
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"columns=%.20g rows=%.20g depth=%.20g\n",(double) image->columns,
(double) image->rows,(double) image->depth);
(void) WriteBlobString(image,buffer);
if (image->type != UndefinedType)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"type=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"type=%s\n",
CommandOptionToMnemonic(MagickTypeOptions,image->type));
(void) WriteBlobString(image,buffer);
}
- if (image->colorspace != UndefinedColorspace)
- {
- (void) FormatLocaleString(buffer,MaxTextExtent,"colorspace=%s\n",
- CommandOptionToMnemonic(MagickColorspaceOptions,image->colorspace));
- (void) WriteBlobString(image,buffer);
- }
+ (void) FormatLocaleString(buffer,MagickPathExtent,"colorspace=%s\n",
+ CommandOptionToMnemonic(MagickColorspaceOptions,image->colorspace));
+ (void) WriteBlobString(image,buffer);
if (image->intensity != UndefinedPixelIntensityMethod)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"pixel-intensity=%s\n",
- CommandOptionToMnemonic(MagickPixelIntensityOptions,
- image->intensity));
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "pixel-intensity=%s\n",CommandOptionToMnemonic(
+ MagickPixelIntensityOptions,image->intensity));
(void) WriteBlobString(image,buffer);
}
if (image->endian != UndefinedEndian)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"endian=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"endian=%s\n",
CommandOptionToMnemonic(MagickEndianOptions,image->endian));
(void) WriteBlobString(image,buffer);
}
if (image->compression != UndefinedCompression)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"compression=%s quality=%.20g\n",CommandOptionToMnemonic(
MagickCompressOptions,image->compression),(double) image->quality);
(void) WriteBlobString(image,buffer);
}
if (image->units != UndefinedResolution)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"units=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"units=%s\n",
CommandOptionToMnemonic(MagickResolutionOptions,image->units));
(void) WriteBlobString(image,buffer);
}
if ((image->resolution.x != 0) || (image->resolution.y != 0))
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"resolution=%gx%g\n",image->resolution.x,image->resolution.y);
(void) WriteBlobString(image,buffer);
}
if ((image->page.width != 0) || (image->page.height != 0))
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"page=%.20gx%.20g%+.20g%+.20g\n",(double) image->page.width,(double)
image->page.height,(double) image->page.x,(double) image->page.y);
(void) WriteBlobString(image,buffer);
else
if ((image->page.x != 0) || (image->page.y != 0))
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"page=%+ld%+ld\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"page=%+ld%+ld\n",
(long) image->page.x,(long) image->page.y);
(void) WriteBlobString(image,buffer);
}
- if ((image->page.x != 0) || (image->page.y != 0))
+ if ((image->tile_offset.x != 0) || (image->tile_offset.y != 0))
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"tile-offset=%+ld%+ld\n",
- (long) image->tile_offset.x,(long) image->tile_offset.y);
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "tile-offset=%+ld%+ld\n",(long) image->tile_offset.x,(long)
+ image->tile_offset.y);
(void) WriteBlobString(image,buffer);
}
if ((GetNextImageInList(image) != (Image *) NULL) ||
(GetPreviousImageInList(image) != (Image *) NULL))
{
if (image->scene == 0)
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"iterations=%.20g delay=%.20g ticks-per-second=%.20g\n",(double)
image->iterations,(double) image->delay,(double)
image->ticks_per_second);
else
- (void) FormatLocaleString(buffer,MaxTextExtent,"scene=%.20g "
+ (void) FormatLocaleString(buffer,MagickPathExtent,"scene=%.20g "
"iterations=%.20g delay=%.20g ticks-per-second=%.20g\n",
(double) image->scene,(double) image->iterations,(double)
image->delay,(double) image->ticks_per_second);
{
if (image->scene != 0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"scene=%.20g\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"scene=%.20g\n",
(double) image->scene);
(void) WriteBlobString(image,buffer);
}
if (image->iterations != 0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"iterations=%.20g\n",
- (double) image->iterations);
+ (void) FormatLocaleString(buffer,MagickPathExtent,
+ "iterations=%.20g\n",(double) image->iterations);
(void) WriteBlobString(image,buffer);
}
if (image->delay != 0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"delay=%.20g\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"delay=%.20g\n",
(double) image->delay);
(void) WriteBlobString(image,buffer);
}
if (image->ticks_per_second != UndefinedTicksPerSecond)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"ticks-per-second=%.20g\n",(double) image->ticks_per_second);
(void) WriteBlobString(image,buffer);
}
}
if (image->gravity != UndefinedGravity)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"gravity=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"gravity=%s\n",
CommandOptionToMnemonic(MagickGravityOptions,image->gravity));
(void) WriteBlobString(image,buffer);
}
if (image->dispose != UndefinedDispose)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"dispose=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"dispose=%s\n",
CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
(void) WriteBlobString(image,buffer);
}
if (image->rendering_intent != UndefinedIntent)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"rendering-intent=%s\n",CommandOptionToMnemonic(MagickIntentOptions,
image->rendering_intent));
(void) WriteBlobString(image,buffer);
}
if (image->gamma != 0.0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"gamma=%g\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"gamma=%g\n",
image->gamma);
(void) WriteBlobString(image,buffer);
}
/*
Note chomaticity points.
*/
- (void) FormatLocaleString(buffer,MaxTextExtent,"red-primary="
+ (void) FormatLocaleString(buffer,MagickPathExtent,"red-primary="
"%g,%g green-primary=%g,%g blue-primary=%g,%g\n",
image->chromaticity.red_primary.x,image->chromaticity.red_primary.y,
image->chromaticity.green_primary.x,
image->chromaticity.blue_primary.x,
image->chromaticity.blue_primary.y);
(void) WriteBlobString(image,buffer);
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"white-point=%g,%g\n",image->chromaticity.white_point.x,
image->chromaticity.white_point.y);
(void) WriteBlobString(image,buffer);
}
if (image->orientation != UndefinedOrientation)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"orientation=%s\n",CommandOptionToMnemonic(MagickOrientationOptions,
image->orientation));
(void) WriteBlobString(image,buffer);
profile=GetImageProfile(image,name);
if (profile != (StringInfo *) NULL)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"profile:%s=%.20g\n",name,(double)
GetStringInfoLength(profile));
(void) WriteBlobString(image,buffer);
}
if (image->montage != (char *) NULL)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"montage=%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"montage=%s\n",
image->montage);
(void) WriteBlobString(image,buffer);
}
property=GetNextImageProperty(image);
while (property != (const char *) NULL)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"%s=",property);
+ (void) FormatLocaleString(buffer,MagickPathExtent,"%s=",property);
(void) WriteBlobString(image,buffer);
value=GetImageProperty(image,property,exception);
if (value != (const char *) NULL)