% July 1992 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/color-private.h"
-#include "magick/colormap-private.h"
-#include "magick/colorspace.h"
-#include "magick/composite.h"
-#include "magick/constitute.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/log.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/profile.h"
-#include "magick/resource_.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/transform.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/colormap-private.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/composite.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/log.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/profile.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/transform.h"
+#include "MagickCore/utility.h"
\f
/*
ImageMagick Macintosh PICT Methods.
const char
*name;
- long
+ ssize_t
length;
const char
version,
pack_type;
- unsigned long
+ size_t
pack_size,
horizontal_resolution,
vertical_resolution;
component_count,
component_size;
- unsigned long
+ size_t
plane_bytes,
table,
reserved;
/* 0x0b */ { "OvSize", 4, "oval size (point)" },
/* 0x0c */ { "Origin", 4, "dh, dv (word)" },
/* 0x0d */ { "TxSize", 2, "text size (word)" },
- /* 0x0e */ { "FgColor", 4, "foreground color (longword)" },
- /* 0x0f */ { "BkColor", 4, "background color (longword)" },
+ /* 0x0e */ { "FgColor", 4, "foreground color (ssize_tword)" },
+ /* 0x0f */ { "BkColor", 4, "background color (ssize_tword)" },
/* 0x10 */ { "TxRatio", 8, "numerator (point), denominator (point)" },
/* 0x11 */ { "Version", 1, "version (byte)" },
/* 0x12 */ { "BkPixPat", 0, "color background pattern" },
Forward declarations.
*/
static MagickBooleanType
- WritePICTImage(const ImageInfo *,Image *);
+ WritePICTImage(const ImageInfo *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The format of the DecodeImage method is:
%
% unsigned char *DecodeImage(Image *blob,Image *image,
-% unsigned long bytes_per_line,const int bits_per_pixel,
+% size_t bytes_per_line,const int bits_per_pixel,
% unsigned size_t extent)
%
% A description of each parameter follows:
static unsigned char *ExpandBuffer(unsigned char *pixels,
MagickSizeType *bytes_per_line,const unsigned int bits_per_pixel)
{
- register long
+ register ssize_t
i;
register unsigned char
return(pixels);
case 4:
{
- for (i=0; i < (long) *bytes_per_line; i++)
+ for (i=0; i < (ssize_t) *bytes_per_line; i++)
{
*q++=(*p >> 4) & 0xff;
*q++=(*p & 15);
}
case 2:
{
- for (i=0; i < (long) *bytes_per_line; i++)
+ for (i=0; i < (ssize_t) *bytes_per_line; i++)
{
*q++=(*p >> 6) & 0x03;
*q++=(*p >> 4) & 0x03;
}
case 1:
{
- for (i=0; i < (long) *bytes_per_line; i++)
+ for (i=0; i < (ssize_t) *bytes_per_line; i++)
{
*q++=(*p >> 7) & 0x01;
*q++=(*p >> 6) & 0x01;
}
static unsigned char *DecodeImage(Image *blob,Image *image,
- unsigned long bytes_per_line,const unsigned int bits_per_pixel,size_t *extent)
+ size_t bytes_per_line,const unsigned int bits_per_pixel,size_t *extent,
+ ExceptionInfo *exception)
{
- long
- j,
- y;
-
MagickSizeType
number_pixels;
- register long
+ register ssize_t
i;
register unsigned char
*q;
size_t
+ bytes_per_pixel,
length,
- row_bytes;
+ row_bytes,
+ scanline_length,
+ width;
ssize_t
- count;
+ count,
+ j,
+ y;
unsigned char
*pixels,
*scanline;
- unsigned long
- bytes_per_pixel,
- scanline_length,
- width;
-
/*
Determine pixel buffer size.
*/
/*
Pixels are already uncompressed.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- q=pixels+y*width;
+ q=pixels+y*width*GetPixelChannels(image);;
number_pixels=bytes_per_line;
count=ReadBlob(blob,(size_t) number_pixels,scanline);
+ (void) count;
p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
if ((q+number_pixels) > (pixels+(*extent)))
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",
image->filename);
break;
/*
Uncompress RLE pixels into uncompressed pixel buffer.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=pixels+y*width;
if (bytes_per_line > 200)
scanline_length=1UL*ReadBlobByte(blob);
if (scanline_length >= row_bytes)
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",image->filename);
break;
}
count=ReadBlob(blob,scanline_length,scanline);
- for (j=0; j < (long) scanline_length; )
+ for (j=0; j < (ssize_t) scanline_length; )
if ((scanline[j] & 0x80) == 0)
{
length=(size_t) ((scanline[j] & 0xff)+1);
if ((q-pixels+number_pixels) <= *extent)
(void) CopyMagickMemory(q,p,(size_t) number_pixels);
q+=number_pixels;
- j+=(long) (length*bytes_per_pixel+1);
+ j+=(ssize_t) (length*bytes_per_pixel+1);
}
else
{
length=(size_t) (((scanline[j] ^ 0xff) & 0xff)+2);
number_pixels=bytes_per_pixel;
p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
- for (i=0; i < (long) length; i++)
+ for (i=0; i < (ssize_t) length; i++)
{
if ((q-pixels+number_pixels) <= *extent)
(void) CopyMagickMemory(q,p,(size_t) number_pixels);
q+=number_pixels;
}
- j+=bytes_per_pixel+1;
+ j+=(ssize_t) bytes_per_pixel+1;
}
}
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
% The format of the EncodeImage method is:
%
% size_t EncodeImage(Image *image,const unsigned char *scanline,
-% const unsigned long bytes_per_line,unsigned char *pixels)
+% const size_t bytes_per_line,unsigned char *pixels)
%
% A description of each parameter follows:
%
%
*/
static size_t EncodeImage(Image *image,const unsigned char *scanline,
- const unsigned long bytes_per_line,unsigned char *pixels)
+ const size_t bytes_per_line,unsigned char *pixels)
{
#define MaxCount 128
#define MaxPackbitsRunlength 128
- long
- count,
- repeat_count,
- runlength;
-
register const unsigned char
*p;
- register long
+ register ssize_t
i;
register unsigned char
size_t
length;
+ ssize_t
+ count,
+ repeat_count,
+ runlength;
+
unsigned char
index;
p=scanline+(bytes_per_line-1);
q=pixels;
index=(*p);
- for (i=(long) bytes_per_line-1; i >= 0; i--)
+ for (i=(ssize_t) bytes_per_line-1; i >= 0; i--)
{
if (index == *p)
runlength++;
%
*/
-static inline unsigned long MagickMax(const unsigned long x,
- const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+ const size_t y)
{
if (x > y)
return(x);
Image
*image;
- IndexPacket
- index;
-
int
c,
code;
- long
- flags,
- j,
- version,
- y;
-
MagickBooleanType
jpeg,
status;
PICTPixmap
pixmap;
- register IndexPacket
- *indexes;
-
- register long
- x;
+ Quantum
+ index;
- register PixelPacket
+ register Quantum
*q;
- register long
- i;
+ register ssize_t
+ i,
+ x;
size_t
extent,
length;
ssize_t
- count;
+ count,
+ flags,
+ j,
+ version,
+ y;
StringInfo
*profile;
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
image->depth=8;
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
flags=0;
image->columns=1UL*(frame.right-frame.left);
image->rows=1UL*(frame.bottom-frame.top);
- image->x_resolution=DefaultResolution;
- image->y_resolution=DefaultResolution;
+ image->resolution.x=DefaultResolution;
+ image->resolution.y=DefaultResolution;
image->units=UndefinedResolution;
/*
Interpret PICT opcodes.
length=ReadBlobMSBShort(image);
if (length != 0x000a)
{
- for (i=0; i < (long) (length-2); i++)
+ for (i=0; i < (ssize_t) (length-2); i++)
(void) ReadBlobByte(image);
break;
}
break;
image->columns=1UL*(frame.right-frame.left);
image->rows=1UL*(frame.bottom-frame.top);
- (void) SetImageBackgroundColor(image);
+ (void) SetImageBackgroundColor(image,exception);
break;
}
case 0x12:
case 0x13:
case 0x14:
{
- long
+ ssize_t
pattern;
- unsigned long
+ size_t
height,
width;
ReadRectangle(image,frame);
ReadPixmap(pixmap);
image->depth=1UL*pixmap.component_size;
- image->x_resolution=1.0*pixmap.horizontal_resolution;
- image->y_resolution=1.0*pixmap.vertical_resolution;
+ image->resolution.x=1.0*pixmap.horizontal_resolution;
+ image->resolution.y=1.0*pixmap.vertical_resolution;
image->units=PixelsPerInchResolution;
(void) ReadBlobMSBLong(image);
flags=1L*ReadBlobMSBShort(image);
length=ReadBlobMSBShort(image);
- for (i=0; i <= (long) length; i++)
+ for (i=0; i <= (ssize_t) length; i++)
(void) ReadBlobMSBLong(image);
width=1UL*(frame.bottom-frame.top);
height=1UL*(frame.right-frame.left);
length=width;
if (length < 8)
{
- for (i=0; i < (long) (length*height); i++)
+ for (i=0; i < (ssize_t) (length*height); i++)
(void) ReadBlobByte(image);
}
else
for (j=0; j < (int) height; j++)
if (length > 200)
- for (j=0; j < (long) ReadBlobMSBShort(image); j++)
+ for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++)
(void) ReadBlobByte(image);
else
- for (j=0; j < (long) ReadBlobByte(image); j++)
+ for (j=0; j < (ssize_t) ReadBlobByte(image); j++)
(void) ReadBlobByte(image);
break;
}
Skip polygon or region.
*/
length=ReadBlobMSBShort(image);
- for (i=0; i < (long) (length-2); i++)
+ for (i=0; i < (ssize_t) (length-2); i++)
(void) ReadBlobByte(image);
break;
}
case 0x9a:
case 0x9b:
{
- long
- bytes_per_line;
+ Image
+ *tile_image;
PICTRectangle
source,
size_t
j;
+ ssize_t
+ bytes_per_line;
+
unsigned char
*pixels;
- Image
- *tile_image;
-
/*
Pixmap clipped by a rectangle.
*/
tile_image->depth=1UL*pixmap.component_size;
tile_image->matte=pixmap.component_count == 4 ?
MagickTrue : MagickFalse;
- tile_image->x_resolution=(double) pixmap.horizontal_resolution;
- tile_image->y_resolution=(double) pixmap.vertical_resolution;
+ tile_image->resolution.x=(double) pixmap.horizontal_resolution;
+ tile_image->resolution.y=(double) pixmap.vertical_resolution;
tile_image->units=PixelsPerInchResolution;
if (tile_image->matte != MagickFalse)
image->matte=tile_image->matte;
flags=1L*ReadBlobMSBShort(image);
tile_image->colors=1UL*ReadBlobMSBShort(image)+1;
}
- status=AcquireImageColormap(tile_image,tile_image->colors);
+ status=AcquireImageColormap(tile_image,tile_image->colors,
+ exception);
if (status == MagickFalse)
{
tile_image=DestroyImage(tile_image);
}
if ((bytes_per_line & 0x8000) != 0)
{
- for (i=0; i < (long) tile_image->colors; i++)
+ for (i=0; i < (ssize_t) tile_image->colors; i++)
{
j=ReadBlobMSBShort(image) % tile_image->colors;
if ((flags & 0x8000) != 0)
}
else
{
- for (i=0; i < (long) tile_image->colors; i++)
+ for (i=0; i < (ssize_t) tile_image->colors; i++)
{
tile_image->colormap[i].red=(Quantum) (QuantumRange-
tile_image->colormap[i].red);
Skip region.
*/
length=ReadBlobMSBShort(image);
- for (i=0; i < (long) (length-2); i++)
+ for (i=0; i < (ssize_t) (length-2); i++)
(void) ReadBlobByte(image);
}
if ((code != 0x9a) && (code != 0x9b) &&
(bytes_per_line & 0x8000) == 0)
- pixels=DecodeImage(image,tile_image,1UL*bytes_per_line,1,&extent);
+ pixels=DecodeImage(image,tile_image,1UL*bytes_per_line,1,&extent,
+ exception);
else
pixels=DecodeImage(image,tile_image,1UL*bytes_per_line,1U*
- pixmap.bits_per_pixel,&extent);
+ pixmap.bits_per_pixel,&extent,exception);
if (pixels == (unsigned char *) NULL)
{
tile_image=DestroyImage(tile_image);
Convert PICT tile image to pixel packets.
*/
p=pixels;
- for (y=0; y < (long) tile_image->rows; y++)
+ for (y=0; y < (ssize_t) tile_image->rows; y++)
{
if (p > (pixels+extent+image->columns))
ThrowReaderException(CorruptImageError,"NotEnoughPixelData");
q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1,
exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(tile_image);
- for (x=0; x < (long) tile_image->columns; x++)
+ for (x=0; x < (ssize_t) tile_image->columns; x++)
{
if (tile_image->storage_class == PseudoClass)
{
- index=ConstrainColormapIndex(tile_image,*p);
- indexes[x]=index;
- q->red=tile_image->colormap[(long) index].red;
- q->green=tile_image->colormap[(long) index].green;
- q->blue=tile_image->colormap[(long) index].blue;
+ index=ConstrainColormapIndex(tile_image,*p,exception);
+ SetPixelIndex(tile_image,index,q);
+ SetPixelRed(tile_image,
+ tile_image->colormap[(ssize_t) index].red,q);
+ SetPixelGreen(tile_image,
+ tile_image->colormap[(ssize_t) index].green,q);
+ SetPixelBlue(tile_image,
+ tile_image->colormap[(ssize_t) index].blue,q);
}
else
{
{
i=(*p++);
j=(*p);
- q->red=ScaleCharToQuantum((unsigned char)
- ((i & 0x7c) << 1));
- q->green=ScaleCharToQuantum((unsigned char)
- (((i & 0x03) << 6) | ((j & 0xe0) >> 2)));
- q->blue=ScaleCharToQuantum((unsigned char)
- ((j & 0x1f) << 3));
+ SetPixelRed(tile_image,ScaleCharToQuantum(
+ (unsigned char) ((i & 0x7c) << 1)),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(
+ (unsigned char) (((i & 0x03) << 6) |
+ ((j & 0xe0) >> 2))),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(
+ (unsigned char) ((j & 0x1f) << 3)),q);
}
else
if (tile_image->matte == MagickFalse)
if (p > (pixels+extent+2*image->columns))
ThrowReaderException(CorruptImageError,
"NotEnoughPixelData");
- q->red=ScaleCharToQuantum(*p);
- q->green=ScaleCharToQuantum(
- *(p+tile_image->columns));
- q->blue=ScaleCharToQuantum(
- *(p+2*tile_image->columns));
+ SetPixelRed(tile_image,ScaleCharToQuantum(*p),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(
+ *(p+tile_image->columns)),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(
+ *(p+2*tile_image->columns)),q);
}
else
{
if (p > (pixels+extent+3*image->columns))
ThrowReaderException(CorruptImageError,
"NotEnoughPixelData");
- q->opacity=(Quantum) (QuantumRange-
- ScaleCharToQuantum(*p));
- q->red=ScaleCharToQuantum(*(p+tile_image->columns));
- q->green=(Quantum) ScaleCharToQuantum(
- *(p+2*tile_image->columns));
- q->blue=ScaleCharToQuantum(
- *(p+3*tile_image->columns));
+ SetPixelAlpha(tile_image,ScaleCharToQuantum(*p),q);
+ SetPixelRed(tile_image,ScaleCharToQuantum(
+ *(p+tile_image->columns)),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(
+ *(p+2*tile_image->columns)),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(
+ *(p+3*tile_image->columns)),q);
}
}
p++;
- q++;
+ q+=GetPixelChannels(tile_image);
}
if (SyncAuthenticPixels(tile_image,exception) == MagickFalse)
break;
if (jpeg == MagickFalse)
if ((code == 0x9a) || (code == 0x9b) ||
((bytes_per_line & 0x8000) != 0))
- (void) CompositeImage(image,CopyCompositeOp,tile_image,
- destination.left,destination.top);
+ (void) CompositeImage(image,tile_image,CopyCompositeOp,
+ MagickTrue,destination.left,destination.top,exception);
tile_image=DestroyImage(tile_image);
break;
}
unsigned char
*info;
- unsigned long
+ size_t
type;
/*
if (info == (unsigned char *) NULL)
break;
count=ReadBlob(image,length,info);
+ (void) count;
switch (type)
{
case 0xe0:
{
if (length == 0)
break;
- profile=AcquireStringInfo(length);
+ profile=BlobToStringInfo((const void *) NULL,length);
SetStringInfoDatum(profile,info);
- status=SetImageProfile(image,"icc",profile);
+ status=SetImageProfile(image,"icc",profile,exception);
profile=DestroyStringInfo(profile);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,
{
if (length == 0)
break;
- profile=AcquireStringInfo(length);
+ profile=BlobToStringInfo((const void *) NULL,length);
SetStringInfoDatum(profile,info);
- status=SetImageProfile(image,"iptc",profile);
+ status=SetImageProfile(image,"iptc",profile,exception);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
if (codes[code].length == -1)
(void) ReadBlobMSBShort(image);
else
- for (i=0; i < (long) codes[code].length; i++)
+ for (i=0; i < (ssize_t) codes[code].length; i++)
(void) ReadBlobByte(image);
}
}
ReadRectangle(image,frame);
for (i=0; i < 122; i++)
(void) ReadBlobByte(image);
- for (i=0; i < (long) (length-154); i++)
+ for (i=0; i < (ssize_t) (length-154); i++)
{
c=ReadBlobByte(image);
(void) fputc(c,file);
read_info=DestroyImageInfo(read_info);
if (tile_image == (Image *) NULL)
continue;
- (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu",
+ (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g",
+ (double) MagickMax(image->columns,tile_image->columns),
+ (double) MagickMax(image->rows,tile_image->rows));
+ (void) SetImageExtent(image,
MagickMax(image->columns,tile_image->columns),
- MagickMax(image->rows,tile_image->rows));
- (void) TransformImage(&image,(char *) NULL,geometry);
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,tile_image->colorspace);
- (void) CompositeImage(image,CopyCompositeOp,tile_image,frame.left,
- frame.right);
+ MagickMax(image->rows,tile_image->rows),exception);
+ if (IssRGBCompatibleColorspace(tile_image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,tile_image->colorspace,
+ exception);
+ (void) CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue,
+ frame.left,frame.right,exception);
image->compression=tile_image->compression;
tile_image=DestroyImage(tile_image);
continue;
Skip reserved.
*/
length=ReadBlobMSBShort(image);
- for (i=0; i < (long) length; i++)
+ for (i=0; i < (ssize_t) length; i++)
(void) ReadBlobByte(image);
continue;
}
Skip reserved.
*/
length=(size_t) ((code >> 7) & 0xff);
- for (i=0; i < (long) length; i++)
+ for (i=0; i < (ssize_t) length; i++)
(void) ReadBlobByte(image);
continue;
}
%
% The format of the RegisterPICTImage method is:
%
-% unsigned long RegisterPICTImage(void)
+% size_t RegisterPICTImage(void)
%
*/
-ModuleExport unsigned long RegisterPICTImage(void)
+ModuleExport size_t RegisterPICTImage(void)
{
MagickInfo
*entry;
entry->decoder=(DecodeImageHandler *) ReadPICTImage;
entry->encoder=(EncodeImageHandler *) WritePICTImage;
entry->adjoin=MagickFalse;
+ entry->seekable_stream=MagickTrue;
entry->description=ConstantString("Apple Macintosh QuickDraw/PICT");
entry->magick=(IsImageFormatHandler *) IsPICT;
entry->module=ConstantString("PICT");
entry->decoder=(DecodeImageHandler *) ReadPICTImage;
entry->encoder=(EncodeImageHandler *) WritePICTImage;
entry->adjoin=MagickFalse;
+ entry->seekable_stream=MagickTrue;
entry->description=ConstantString("Apple Macintosh QuickDraw/PICT");
entry->magick=(IsImageFormatHandler *) IsPICT;
entry->module=ConstantString("PICT");
% The format of the WritePICTImage method is:
%
% MagickBooleanType WritePICTImage(const ImageInfo *image_info,
-% Image *image)
+% Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
%
% o image: The image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static MagickBooleanType WritePICTImage(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
#define MaxCount 128
#define PictCropRegionOp 0x01
x_resolution,
y_resolution;
- long
- y;
-
MagickBooleanType
status;
size_rectangle,
source_rectangle;
- register const IndexPacket
- *indexes;
-
- register const PixelPacket
+ register const Quantum
*p;
- register long
+ register ssize_t
i,
x;
size_t
- count;
+ bytes_per_line,
+ count,
+ storage_class;
+
+ ssize_t
+ y;
unsigned char
*buffer,
*packed_scanline,
*scanline;
- unsigned long
- bytes_per_line,
- storage_class;
-
unsigned short
base_address,
row_bytes,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if ((image->columns > 65535L) || (image->rows > 65535L))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
/*
Initialize image info.
*/
pixmap.table=0;
pixmap.reserved=0;
transfer_mode=0;
- x_resolution=image->x_resolution != 0.0 ? image->x_resolution :
+ x_resolution=image->resolution.x != 0.0 ? image->resolution.x :
DefaultResolution;
- y_resolution=image->y_resolution != 0.0 ? image->y_resolution :
+ y_resolution=image->resolution.y != 0.0 ? image->resolution.y :
DefaultResolution;
storage_class=image->storage_class;
if (image_info->compression == JPEGCompression)
unsigned char
*blob;
- jpeg_image=CloneImage(image,0,0,MagickTrue,&image->exception);
+ jpeg_image=CloneImage(image,0,0,MagickTrue,exception);
if (jpeg_image == (Image *) NULL)
{
(void) CloseBlob(image);
(void) CopyMagickString(jpeg_info->magick,"JPEG",MaxTextExtent);
length=0;
blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length,
- &image->exception);
+ exception);
jpeg_info=DestroyImageInfo(jpeg_info);
if (blob == (unsigned char *) NULL)
return(MagickFalse);
jpeg_image=DestroyImage(jpeg_image);
(void) WriteBlobMSBShort(image,PictJPEGOp);
- (void) WriteBlobMSBLong(image,(unsigned long) length+154);
+ (void) WriteBlobMSBLong(image,(unsigned int) length+154);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBLong(image,0x00010000UL);
(void) WriteBlobMSBLong(image,0x00000000UL);
else
{
(void) WriteBlobMSBShort(image,PictPixmapOp);
- (void) WriteBlobMSBLong(image,(unsigned long) base_address);
+ (void) WriteBlobMSBLong(image,(size_t) base_address);
}
(void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000));
(void) WriteBlobMSBShort(image,(unsigned short) bounds.top);
*/
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.version);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type);
- (void) WriteBlobMSBLong(image,pixmap.pack_size);
+ (void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size);
(void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5));
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5));
*/
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size);
- (void) WriteBlobMSBLong(image,(unsigned long) pixmap.plane_bytes);
- (void) WriteBlobMSBLong(image,(unsigned long) pixmap.table);
- (void) WriteBlobMSBLong(image,(unsigned long) pixmap.reserved);
+ (void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes);
+ (void) WriteBlobMSBLong(image,(unsigned int) pixmap.table);
+ (void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved);
if (storage_class == PseudoClass)
{
/*
(void) WriteBlobMSBLong(image,0x00000000L); /* color seed */
(void) WriteBlobMSBShort(image,0L); /* color flags */
(void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1));
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
{
(void) WriteBlobMSBShort(image,(unsigned short) i);
(void) WriteBlobMSBShort(image,ScaleQuantumToShort(
*/
count=0;
if ((storage_class == PseudoClass) && (image->matte == MagickFalse))
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- indexes=GetVirtualIndexQueue(image);
- for (x=0; x < (long) image->columns; x++)
- scanline[x]=(unsigned char) indexes[x];
- count+=EncodeImage(image,scanline,(unsigned long) (row_bytes & 0x7FFF),
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ scanline[x]=(unsigned char) GetPixelIndex(image,p);
+ p+=GetPixelChannels(image);
+ }
+ count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
packed_scanline);
- if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
- (QuantumTick(y,image->rows) != MagickFalse))
+ if (image->previous == (Image *) NULL)
{
- status=image->progress_monitor(SaveImageTag,y,image->rows,
- image->client_data);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
if (image_info->compression == JPEGCompression)
{
(void) ResetMagickMemory(scanline,0,row_bytes);
- for (y=0; y < (long) image->rows; y++)
- count+=EncodeImage(image,scanline,(unsigned long)
- (row_bytes & 0x7FFF),packed_scanline);
+ for (y=0; y < (ssize_t) image->rows; y++)
+ count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
+ packed_scanline);
}
else
{
green=scanline+image->columns;
blue=scanline+2*image->columns;
opacity=scanline+3*image->columns;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
red=scanline;
green=scanline+image->columns;
green=scanline+2*image->columns;
blue=scanline+3*image->columns;
}
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- *red++=ScaleQuantumToChar(GetRedPixelComponent(p));
- *green++=ScaleQuantumToChar(GetGreenPixelComponent(p));
- *blue++=ScaleQuantumToChar(GetBluePixelComponent(p));
+ *red++=ScaleQuantumToChar(GetPixelRed(image,p));
+ *green++=ScaleQuantumToChar(GetPixelGreen(image,p));
+ *blue++=ScaleQuantumToChar(GetPixelBlue(image,p));
if (image->matte != MagickFalse)
- *opacity++=ScaleQuantumToChar((Quantum)
- (QuantumRange-GetOpacityPixelComponent(p)));
- p++;
+ *opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p)));
+ p+=GetPixelChannels(image);
}
count+=EncodeImage(image,scanline,bytes_per_line & 0x7FFF,
packed_scanline);
- if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
- (QuantumTick(y,image->rows) != MagickFalse))
+ if (image->previous == (Image *) NULL)
{
- status=image->progress_monitor(SaveImageTag,y,image->rows,
- image->client_data);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}