% July 1992 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2010 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 declarations.
*/
#include "magick/studio.h"
+#include "magick/attribute.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/color.h"
-#include "magick/colormap-private.h"
#include "magick/color-private.h"
+#include "magick/colormap.h"
+#include "magick/colormap-private.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/exception.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"
#if defined(MAGICKCORE_ZLIB_DELEGATE)
#include "zlib.h"
#endif
(void) ThrowMagickException(&image->exception,GetMagickModule(),
CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
}
- *pixel=image->colormap[(long) *index];
+ *pixel=image->colormap[(ssize_t) *index];
switch (image->depth)
{
case 8:
}
case 32:
{
- unsigned long
+ unsigned int
quantum;
if (image->matte != MagickFalse)
}
case 32:
{
- unsigned long
+ unsigned int
quantum;
p=PushLongPixel(MSBEndian,p,&quantum);
LinkedListInfo
*profiles;
- long
+ ssize_t
y;
MagickBooleanType
QuantumType
quantum_type;
- register long
+ register ssize_t
i;
size_t
*compress_pixels,
*pixels;
- unsigned long
+ size_t
colors;
#if defined(MAGICKCORE_ZLIB_DELEGATE)
} while (c != EOF);
*p='\0';
p=options;
- while (isspace((int) ((unsigned char) c)) != 0)
+ while ((isspace((int) ((unsigned char) c)) != 0) && (c != EOF))
c=ReadBlobByte(image);
if (c == (int) '=')
{
{
if (LocaleCompare(keyword,"class") == 0)
{
- long
+ ssize_t
storage_class;
storage_class=ParseMagickOption(MagickClassOptions,
}
if (LocaleCompare(keyword,"colors") == 0)
{
- colors=(unsigned long) atol(options);
+ 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,"gamma") == 0)
{
- image->gamma=atof(options);
+ image->gamma=StringToDouble(options);
break;
}
if (LocaleCompare(keyword,"gravity") == 0)
{
- long
+ ssize_t
gravity;
gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
}
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,"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-format") == 0) ||
(LocaleCompare(keyword,"quantum:format") == 0))
{
- long
+ ssize_t
format;
format=ParseMagickOption(MagickQuantumFormatOptions,
}
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=atol(options);
+ image->ticks_per_second=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,
{
if (LocaleCompare(keyword,"version") == 0)
{
- version=atof(options);
+ version=StringToDouble(options);
break;
}
(void) SetImageProperty(image,keyword,options);
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);
pixels=GetQuantumPixels(quantum_info);
index=(IndexPacket) 0;
length=0;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
register IndexPacket
- *__restrict indexes;
+ *restrict indexes;
- register long
+ register ssize_t
x;
register PixelPacket
- *__restrict q;
+ *restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
if (inflate(&zip_info,Z_SYNC_FLUSH) == Z_STREAM_END)
break;
} while (zip_info.avail_out != 0);
- if (y == (long) (image->rows-1))
+ if (y == (ssize_t) (image->rows-1))
{
if (version == 0)
{
if (BZ2_bzDecompress(&bzip_info) == BZ_STREAM_END)
break;
} while (bzip_info.avail_out != 0);
- if (y == (long) (image->rows-1))
+ if (y == (ssize_t) (image->rows-1))
{
if (version == 0)
{
pixel.opacity=(Quantum) TransparentOpacity;
index=(IndexPacket) 0;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
if (length == 0)
{
SetQuantumImageType(image,quantum_type);
quantum_info=DestroyQuantumInfo(quantum_info);
compress_pixels=(unsigned char *) RelinquishMagickMemory(compress_pixels);
- if (((y != (long) image->rows)) || (status == MagickFalse))
+ if (((y != (ssize_t) image->rows)) || (status == MagickFalse))
{
image=DestroyImageList(image);
return((Image *) NULL);
%
% The format of the RegisterMIFFImage method is:
%
-% unsigned long RegisterMIFFImage(void)
+% size_t RegisterMIFFImage(void)
%
*/
-ModuleExport unsigned long RegisterMIFFImage(void)
+ModuleExport size_t RegisterMIFFImage(void)
{
char
version[MaxTextExtent];
{
case 32:
{
- *pixels++=(unsigned char) ((unsigned long) index >> 24);
- *pixels++=(unsigned char) ((unsigned long) index >> 16);
+ *pixels++=(unsigned char) ((size_t) index >> 24);
+ *pixels++=(unsigned char) ((size_t) index >> 16);
}
case 16:
- *pixels++=(unsigned char) ((unsigned long) index >> 8);
+ *pixels++=(unsigned char) ((size_t) index >> 8);
case 8:
{
*pixels++=(unsigned char) index;
{
case 32:
{
- unsigned long
+ unsigned int
value;
if (image->matte != MagickFalse)
{
case 32:
{
- unsigned long
+ unsigned int
value;
value=ScaleQuantumToLong(pixel.red);
int
code;
- long
+ ssize_t
y;
MagickBooleanType
QuantumType
quantum_type;
- register long
+ register ssize_t
i;
size_t
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
if ((image->storage_class == PseudoClass) &&
- (image->colors > (unsigned long) (GetQuantumRange(image->depth)+1)))
+ (image->colors > (size_t) (GetQuantumRange(image->depth)+1)))
(void) SetImageStorageClass(image,DirectClass);
if (IsGrayImage(image,&image->exception) != MagickFalse)
{
*/
(void) WriteBlobString(image,"id=ImageMagick version=1.0\n");
(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);
+ (void) FormatMagickString(buffer,MaxTextExtent,"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 (compression != UndefinedCompression)
{
(void) FormatMagickString(buffer,MaxTextExtent,"compression=%s "
- "quality=%lu\n",MagickOptionToMnemonic(MagickCompressOptions,
- compression),image->quality);
+ "quality=%.20g\n",MagickOptionToMnemonic(MagickCompressOptions,
+ 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->tile_offset.x != 0) || (image->tile_offset.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) ||
(GetPreviousImageInList(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);
+ (void) FormatMagickString(buffer,MaxTextExtent,"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);
+ (void) FormatMagickString(buffer,MaxTextExtent,"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);
(void) WriteBlobString(image,buffer);
}
if (quantum_info->format == FloatingPointQuantumFormat)
- SetImageProperty(image,"quantum:format","floating-point");
+ (void) SetImageProperty(image,"quantum:format","floating-point");
ResetImagePropertyIterator(image);
property=GetNextImageProperty(image);
while (property != (const char *) NULL)
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),(const 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 (quantum_info->depth)
{
ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
case 32:
{
- register unsigned long
+ register unsigned int
pixel;
pixel=ScaleQuantumToLong(image->colormap[i].red);
quantum_type=GetQuantumType(image,&image->exception);
pixels=GetQuantumPixels(quantum_info);
status=MagickTrue;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
register const IndexPacket
- *__restrict indexes;
+ *restrict indexes;
register const PixelPacket
- *__restrict p;
+ *restrict p;
- register long
+ register ssize_t
x;
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
(void) WriteBlob(image,length,compress_pixels);
}
} while (zip_info.avail_in != 0);
- if (y == (long) (image->rows-1))
+ if (y == (ssize_t) (image->rows-1))
{
for ( ; ; )
{
(void) WriteBlob(image,length,compress_pixels);
}
} while (bzip_info.avail_in != 0);
- if (y == (long) (image->rows-1))
+ if (y == (ssize_t) (image->rows-1))
{
for ( ; ; )
{
if (indexes != (IndexPacket *) NULL)
index=(*indexes);
length=255;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- if ((length < 255) && (x < (long) (image->columns-1)) &&
+ if ((length < 255) && (x < (ssize_t) (image->columns-1)) &&
(IsColorEqual(p,&pixel) != MagickFalse) &&
((image->matte == MagickFalse) ||
(p->opacity == pixel.opacity)) &&
break;
}
}
- if ((image->previous == (Image *) NULL) &&
- (SetImageProgress(image,SaveImageTag,y,image->rows) == MagickFalse))
- break;
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
+ if (status == MagickFalse)
+ break;
+ }
}
quantum_info=DestroyQuantumInfo(quantum_info);
compress_pixels=(unsigned char *) RelinquishMagickMemory(compress_pixels);