% March 2000 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2011 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 "magick/cache.h"
#include "magick/color.h"
#include "magick/color-private.h"
+#include "magick/colormap.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/memory_.h"
+#include "magick/module.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/option.h"
#include "magick/static.h"
#include "magick/statistic.h"
#include "magick/string_.h"
-#include "magick/module.h"
+#include "magick/string-private.h"
#include "magick/utility.h"
\f
/*
MagickStatusType
flags;
- register long
+ register ssize_t
i;
size_t
StringInfo
*profile;
- unsigned long
+ size_t
depth,
quantum_depth;
{
if (LocaleCompare(keyword,"class") == 0)
{
- long
+ ssize_t
storage_class;
storage_class=ParseMagickOption(MagickClassOptions,
}
if (LocaleCompare(keyword,"colors") == 0)
{
- image->colors=(unsigned long) atol(options);
+ image->colors=StringToUnsignedLong(options);
break;
}
if (LocaleCompare(keyword,"colorspace") == 0)
{
- long
+ ssize_t
colorspace;
colorspace=ParseMagickOption(MagickColorspaceOptions,
}
if (LocaleCompare(keyword,"compression") == 0)
{
- long
+ ssize_t
compression;
compression=ParseMagickOption(MagickCompressOptions,
}
if (LocaleCompare(keyword,"columns") == 0)
{
- image->columns=(unsigned long) atol(options);
+ image->columns=StringToUnsignedLong(options);
break;
}
(void) SetImageProperty(image,keyword,options);
{
if (LocaleCompare(keyword,"delay") == 0)
{
- image->delay=(unsigned long) atol(options);
+ image->delay=StringToUnsignedLong(options);
break;
}
if (LocaleCompare(keyword,"depth") == 0)
{
- image->depth=(unsigned long) atol(options);
+ image->depth=StringToUnsignedLong(options);
break;
}
if (LocaleCompare(keyword,"dispose") == 0)
{
- long
+ ssize_t
dispose;
dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,
{
if (LocaleCompare(keyword,"endian") == 0)
{
- long
+ ssize_t
endian;
endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
}
if (LocaleCompare(keyword,"error") == 0)
{
- image->error.mean_error_per_pixel=atof(options);
+ image->error.mean_error_per_pixel=StringToDouble(options);
break;
}
(void) SetImageProperty(image,keyword,options);
{
if (LocaleCompare(keyword,"gamma") == 0)
{
- image->gamma=atof(options);
+ image->gamma=StringToDouble(options);
break;
}
if (LocaleCompare(keyword,"green-primary") == 0)
}
if (LocaleCompare(keyword,"iterations") == 0)
{
- image->iterations=(unsigned long) atol(options);
+ image->iterations=StringToUnsignedLong(options);
break;
}
(void) SetImageProperty(image,keyword,options);
{
if (LocaleCompare(keyword,"matte") == 0)
{
- long
+ ssize_t
matte;
matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
}
if (LocaleCompare(keyword,"maximum-error") == 0)
{
- image->error.normalized_maximum_error=atof(options);
+ image->error.normalized_maximum_error=StringToDouble(options);
break;
}
if (LocaleCompare(keyword,"mean-error") == 0)
{
- image->error.normalized_mean_error=atof(options);
+ image->error.normalized_mean_error=StringToDouble(options);
break;
}
if (LocaleCompare(keyword,"montage") == 0)
{
if (LocaleCompare(keyword,"opaque") == 0)
{
- long
+ ssize_t
matte;
matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
}
if (LocaleCompare(keyword,"orientation") == 0)
{
- long
+ ssize_t
orientation;
orientation=ParseMagickOption(MagickOrientationOptions,
profiles=NewLinkedList(0);
(void) AppendValueToLinkedList(profiles,
AcquireString(keyword+8));
- profile=AcquireStringInfo((size_t) atol(options));
+ profile=AcquireStringInfo((size_t) StringToLong(options));
(void) SetImageProfile(image,keyword+8,profile);
profile=DestroyStringInfo(profile);
break;
{
if (LocaleCompare(keyword,"quality") == 0)
{
- image->quality=(unsigned long) atol(options);
+ image->quality=StringToUnsignedLong(options);
break;
}
if (LocaleCompare(keyword,"quantum-depth") == 0)
{
- quantum_depth=(unsigned long) atol(options);
+ quantum_depth=StringToUnsignedLong(options);
break;
}
(void) SetImageProperty(image,keyword,options);
}
if (LocaleCompare(keyword,"rendering-intent") == 0)
{
- long
+ ssize_t
rendering_intent;
rendering_intent=ParseMagickOption(MagickIntentOptions,
}
if (LocaleCompare(keyword,"rows") == 0)
{
- image->rows=(unsigned long) atol(options);
+ image->rows=StringToUnsignedLong(options);
break;
}
(void) SetImageProperty(image,keyword,options);
{
if (LocaleCompare(keyword,"scene") == 0)
{
- image->scene=(unsigned long) atol(options);
+ image->scene=StringToUnsignedLong(options);
break;
}
(void) SetImageProperty(image,keyword,options);
{
if (LocaleCompare(keyword,"ticks-per-second") == 0)
{
- image->ticks_per_second=(long) atol(options);
+ image->ticks_per_second=(ssize_t) StringToLong(options);
break;
}
if (LocaleCompare(keyword,"tile-offset") == 0)
}
if (LocaleCompare(keyword,"type") == 0)
{
- long
+ ssize_t
type;
type=ParseMagickOption(MagickTypeOptions,MagickFalse,
{
if (LocaleCompare(keyword,"units") == 0)
{
- long
+ ssize_t
units;
units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
unsigned char
pixel;
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushCharPixel(p,&pixel);
image->colormap[i].red=ScaleCharToQuantum(pixel);
unsigned short
pixel;
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushShortPixel(MSBEndian,p,&pixel);
image->colormap[i].red=ScaleShortToQuantum(pixel);
}
case 32:
{
- unsigned long
+ unsigned int
pixel;
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
p=PushLongPixel(MSBEndian,p,&pixel);
image->colormap[i].red=ScaleLongToQuantum(pixel);
%
% The format of the RegisterMPCImage method is:
%
-% unsigned long RegisterMPCImage(void)
+% size_t RegisterMPCImage(void)
%
*/
-ModuleExport unsigned long RegisterMPCImage(void)
+ModuleExport size_t RegisterMPCImage(void)
{
MagickInfo
*entry;
offset,
scene;
- register long
+ register ssize_t
i;
- unsigned long
- depth;
+ size_t
+ depth,
+ one;
/*
Open persistent cache.
AppendImageFormat("cache",cache_filename);
scene=0;
offset=0;
+ one=1;
do
{
/*
*/
depth=GetImageQuantumDepth(image,MagickTrue);
if ((image->storage_class == PseudoClass) &&
- (image->colors > (1UL << depth)))
+ (image->colors > (one << depth)))
image->storage_class=DirectClass;
(void) WriteBlobString(image,"id=MagickCache\n");
(void) FormatMagickString(buffer,MaxTextExtent,"quantum-depth=%d\n",
MAGICKCORE_QUANTUM_DEPTH);
(void) WriteBlobString(image,buffer);
(void) FormatMagickString(buffer,MaxTextExtent,
- "class=%s colors=%lu matte=%s\n",MagickOptionToMnemonic(
- MagickClassOptions,image->storage_class),image->colors,
- MagickOptionToMnemonic(MagickBooleanOptions,(long) image->matte));
+ "class=%s colors=%.20g matte=%s\n",MagickOptionToMnemonic(
+ MagickClassOptions,image->storage_class),(double) image->colors,
+ MagickOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
(void) WriteBlobString(image,buffer);
(void) FormatMagickString(buffer,MaxTextExtent,
- "columns=%lu rows=%lu depth=%lu\n",image->columns,image->rows,
- image->depth);
+ "columns=%.20g rows=%.20g depth=%.20g\n",(double) image->columns,
+ (double) image->rows,(double) image->depth);
(void) WriteBlobString(image,buffer);
if (image->type != UndefinedType)
{
if (image->compression != UndefinedCompression)
{
(void) FormatMagickString(buffer,MaxTextExtent,
- "compression=%s quality=%lu\n",MagickOptionToMnemonic(
- MagickCompressOptions,image->compression),image->quality);
+ "compression=%s quality=%.20g\n",MagickOptionToMnemonic(
+ MagickCompressOptions,image->compression),(double) image->quality);
(void) WriteBlobString(image,buffer);
}
if (image->units != UndefinedResolution)
}
if ((image->x_resolution != 0) || (image->y_resolution != 0))
{
- (void) FormatMagickString(buffer,MaxTextExtent,"resolution=%gx%g\n",
- image->x_resolution,image->y_resolution);
+ (void) FormatMagickString(buffer,MaxTextExtent,
+ "resolution=%gx%g\n",image->x_resolution,image->y_resolution);
(void) WriteBlobString(image,buffer);
}
if ((image->page.width != 0) || (image->page.height != 0))
{
- (void) FormatMagickString(buffer,MaxTextExtent,"page=%lux%lu%+ld%+ld\n",
- image->page.width,image->page.height,image->page.x,image->page.y);
+ (void) FormatMagickString(buffer,MaxTextExtent,
+ "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) FormatMagickString(buffer,MaxTextExtent,"page=%+ld%+ld\n",
- image->page.x,image->page.y);
+ (long) image->page.x,(long) image->page.y);
(void) WriteBlobString(image,buffer);
}
if ((image->page.x != 0) || (image->page.y != 0))
{
(void) FormatMagickString(buffer,MaxTextExtent,"tile-offset=%+ld%+ld\n",
- image->tile_offset.x,image->tile_offset.y);
+ (long) image->tile_offset.x,(long) image->tile_offset.y);
(void) WriteBlobString(image,buffer);
}
if ((GetNextImageInList(image) != (Image *) NULL) ||
{
if (image->scene == 0)
(void) FormatMagickString(buffer,MaxTextExtent,
- "iterations=%lu delay=%lu ticks-per-second=%lu\n",
- image->iterations,image->delay,image->ticks_per_second);
+ "iterations=%.20g delay=%.20g ticks-per-second=%.20g\n",(double)
+ image->iterations,(double) image->delay,(double)
+ image->ticks_per_second);
else
(void) FormatMagickString(buffer,MaxTextExtent,
- "scene=%lu iterations=%lu delay=%lu ticks-per-second=%lu\n",
- image->scene,image->iterations,image->delay,
- image->ticks_per_second);
+ "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);
(void) WriteBlobString(image,buffer);
}
else
{
if (image->scene != 0)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"scene=%lu\n",
- image->scene);
+ (void) FormatMagickString(buffer,MaxTextExtent,"scene=%.20g\n",
+ (double) image->scene);
(void) WriteBlobString(image,buffer);
}
if (image->iterations != 0)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"iterations=%lu\n",
- image->iterations);
+ (void) FormatMagickString(buffer,MaxTextExtent,"iterations=%.20g\n",
+ (double) image->iterations);
(void) WriteBlobString(image,buffer);
}
if (image->delay != 0)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"delay=%lu\n",
- image->delay);
+ (void) FormatMagickString(buffer,MaxTextExtent,"delay=%.20g\n",
+ (double) image->delay);
(void) WriteBlobString(image,buffer);
}
if (image->ticks_per_second != UndefinedTicksPerSecond)
{
(void) FormatMagickString(buffer,MaxTextExtent,
- "ticks-per-second=%lu\n",image->ticks_per_second);
+ "ticks-per-second=%.20g\n",(double) image->ticks_per_second);
(void) WriteBlobString(image,buffer);
}
}
/*
Note chomaticity points.
*/
- (void) FormatMagickString(buffer,MaxTextExtent,
- "red-primary=%g,%g green-primary=%g,%g blue-primary=%g,%g\n",
+ (void) FormatMagickString(buffer,MaxTextExtent,"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.green_primary.y,
image->chromaticity.blue_primary.x,
image->chromaticity.blue_primary.y);
(void) WriteBlobString(image,buffer);
- (void) FormatMagickString(buffer,MaxTextExtent,"white-point=%g,%g\n",
- image->chromaticity.white_point.x,image->chromaticity.white_point.y);
+ (void) FormatMagickString(buffer,MaxTextExtent,
+ "white-point=%g,%g\n",image->chromaticity.white_point.x,
+ image->chromaticity.white_point.y);
(void) WriteBlobString(image,buffer);
}
if (image->orientation != UndefinedOrientation)
profile=GetImageProfile(image,name);
if (profile != (StringInfo *) NULL)
{
- (void) FormatMagickString(buffer,MaxTextExtent,"profile:%s=%lu\n",
- name,(unsigned long) GetStringInfoLength(profile));
+ (void) FormatMagickString(buffer,MaxTextExtent,
+ "profile:%s=%.20g\n",name,(double)
+ GetStringInfoLength(profile));
(void) WriteBlobString(image,buffer);
}
name=GetNextImageProfile(image);
value=GetImageProperty(image,property);
if (value != (const char *) NULL)
{
- for (i=0; i < (long) strlen(value); i++)
+ for (i=0; i < (ssize_t) strlen(value); i++)
if (isspace((int) ((unsigned char) value[i])) != 0)
break;
- if (i <= (long) strlen(value))
+ if (i <= (ssize_t) strlen(value))
(void) WriteBlobByte(image,'{');
(void) WriteBlob(image,strlen(value),(unsigned char *) value);
- if (i <= (long) strlen(value))
+ if (i <= (ssize_t) strlen(value))
(void) WriteBlobByte(image,'}');
}
(void) WriteBlobByte(image,'\n');
Write colormap to file.
*/
q=colormap;
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
switch (depth)
{
ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
case 32:
{
- unsigned long
+ unsigned int
pixel;
pixel=ScaleQuantumToLong(image->colormap[i].red);