% Read/Write Apple Macintosh QuickDraw/PICT Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2011 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, %
/*
ImageMagick Macintosh PICT Methods.
*/
-#define ReadPixmap(pixmap) \
-{ \
- pixmap.version=(short) ReadBlobMSBShort(image); \
- pixmap.pack_type=(short) ReadBlobMSBShort(image); \
- pixmap.pack_size=ReadBlobMSBLong(image); \
- pixmap.horizontal_resolution=1UL*ReadBlobMSBShort(image); \
- (void) ReadBlobMSBShort(image); \
- pixmap.vertical_resolution=1UL*ReadBlobMSBShort(image); \
- (void) ReadBlobMSBShort(image); \
- pixmap.pixel_type=(short) ReadBlobMSBShort(image); \
- pixmap.bits_per_pixel=(short) ReadBlobMSBShort(image); \
- pixmap.component_count=(short) ReadBlobMSBShort(image); \
- pixmap.component_size=(short) ReadBlobMSBShort(image); \
- pixmap.plane_bytes=ReadBlobMSBLong(image); \
- pixmap.table=ReadBlobMSBLong(image); \
- pixmap.reserved=ReadBlobMSBLong(image); \
- if ((pixmap.bits_per_pixel <= 0) || (pixmap.bits_per_pixel > 32) || \
- (pixmap.component_count <= 0) || (pixmap.component_count > 4) || \
- (pixmap.component_size <= 0)) \
- ThrowReaderException(CorruptImageError,"ImproperImageHeader"); \
-}
-
-#define ReadRectangle(image,rectangle) \
-{ \
- rectangle.top=(short) ReadBlobMSBShort(image); \
- rectangle.left=(short) ReadBlobMSBShort(image); \
- rectangle.bottom=(short) ReadBlobMSBShort(image); \
- rectangle.right=(short) ReadBlobMSBShort(image); \
- if ((rectangle.left > rectangle.right) || \
- (rectangle.top > rectangle.bottom)) \
- ThrowReaderException(CorruptImageError,"ImproperImageHeader"); \
-}
-
typedef struct _PICTCode
{
const char
static unsigned char *DecodeImage(Image *blob,Image *image,
size_t bytes_per_line,const unsigned int bits_per_pixel,size_t *extent)
{
+ MagickBooleanType
+ status;
+
MagickSizeType
number_pixels;
}
else
if (bits_per_pixel == 32)
- width*=image->matte ? 4 : 3;
+ width*=image->alpha_trait ? 4 : 3;
if (bytes_per_line == 0)
bytes_per_line=width;
row_bytes=(size_t) (image->columns | 0x8000);
if (image->storage_class == DirectClass)
- row_bytes=(size_t) ((4*image->columns) | 0x8000);
+ row_bytes=(size_t) (4*(image->columns | 0x8000));
/*
Allocate pixel and scanline buffer.
*/
if (pixels == (unsigned char *) NULL)
return((unsigned char *) NULL);
*extent=row_bytes*image->rows*sizeof(*pixels);
- (void) ResetMagickMemory(pixels,0,*extent);
- scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline));
+ (void) memset(pixels,0,*extent);
+ scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,2*
+ sizeof(*scanline));
if (scanline == (unsigned char *) NULL)
- return((unsigned char *) NULL);
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ return((unsigned char *) NULL);
+ }
+ (void) memset(scanline,0,2*row_bytes*sizeof(*scanline));
+ status=MagickTrue;
if (bytes_per_line < 8)
{
/*
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
- q=pixels+y*width*GetPixelChannels(image);;
+ q=pixels+y*width*GetPixelChannels(image);
number_pixels=bytes_per_line;
count=ReadBlob(blob,(size_t) number_pixels,scanline);
- (void) count;
+ if (count != (ssize_t) number_pixels)
+ {
+ status=MagickFalse;
+ break;
+ }
p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
if ((q+number_pixels) > (pixels+(*extent)))
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CorruptImageError,"UnableToUncompressImage","`%s'",
- image->filename);
+ status=MagickFalse;
break;
}
- (void) CopyMagickMemory(q,p,(size_t) number_pixels);
+ (void) memcpy(q,p,(size_t) number_pixels);
}
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
+ if (status == MagickFalse)
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
return(pixels);
}
/*
if (bytes_per_line > 200)
scanline_length=ReadBlobMSBShort(blob);
else
- scanline_length=1UL*ReadBlobByte(blob);
- if (scanline_length >= row_bytes)
+ scanline_length=(size_t) ReadBlobByte(blob);
+ if ((scanline_length >= row_bytes) || (scanline_length == 0))
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CorruptImageError,"UnableToUncompressImage","`%s'",image->filename);
+ status=MagickFalse;
break;
}
count=ReadBlob(blob,scanline_length,scanline);
+ if (count != (ssize_t) scanline_length)
+ {
+ status=MagickFalse;
+ break;
+ }
for (j=0; j < (ssize_t) scanline_length; )
if ((scanline[j] & 0x80) == 0)
{
number_pixels=length*bytes_per_pixel;
p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
if ((q-pixels+number_pixels) <= *extent)
- (void) CopyMagickMemory(q,p,(size_t) number_pixels);
+ (void) memcpy(q,p,(size_t) number_pixels);
q+=number_pixels;
j+=(ssize_t) (length*bytes_per_pixel+1);
}
for (i=0; i < (ssize_t) length; i++)
{
if ((q-pixels+number_pixels) <= *extent)
- (void) CopyMagickMemory(q,p,(size_t) number_pixels);
+ (void) memcpy(q,p,(size_t) number_pixels);
q+=number_pixels;
}
j+=(ssize_t) bytes_per_pixel+1;
}
}
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
+ if (status == MagickFalse)
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
return(pixels);
}
\f
Pack scanline.
*/
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(scanline != (unsigned char *) NULL);
*/
static MagickBooleanType IsPICT(const unsigned char *magick,const size_t length)
{
+ if (length < 12)
+ return(MagickFalse);
+ /*
+ Embedded OLE2 macintosh have "PICT" instead of 512 platform header.
+ */
+ if (memcmp(magick,"PICT",4) == 0)
+ return(MagickTrue);
if (length < 528)
return(MagickFalse);
if (memcmp(magick+522,"\000\021\002\377\014\000",6) == 0)
%
*/
-static inline size_t MagickMax(const size_t x,
- const size_t y)
+static MagickBooleanType ReadPixmap(Image *image,PICTPixmap *pixmap)
+{
+ pixmap->version=(short) ReadBlobMSBShort(image);
+ pixmap->pack_type=(short) ReadBlobMSBShort(image);
+ pixmap->pack_size=ReadBlobMSBLong(image);
+ pixmap->horizontal_resolution=1UL*ReadBlobMSBShort(image);
+ (void) ReadBlobMSBShort(image);
+ pixmap->vertical_resolution=1UL*ReadBlobMSBShort(image);
+ (void) ReadBlobMSBShort(image);
+ pixmap->pixel_type=(short) ReadBlobMSBShort(image);
+ pixmap->bits_per_pixel=(short) ReadBlobMSBShort(image);
+ pixmap->component_count=(short) ReadBlobMSBShort(image);
+ pixmap->component_size=(short) ReadBlobMSBShort(image);
+ pixmap->plane_bytes=ReadBlobMSBLong(image);
+ pixmap->table=ReadBlobMSBLong(image);
+ pixmap->reserved=ReadBlobMSBLong(image);
+ if ((EOFBlob(image) != MagickFalse) || (pixmap->bits_per_pixel <= 0) ||
+ (pixmap->bits_per_pixel > 32) || (pixmap->component_count <= 0) ||
+ (pixmap->component_count > 4) || (pixmap->component_size <= 0))
+ return(MagickFalse);
+ return(MagickTrue);
+}
+
+static MagickBooleanType ReadRectangle(Image *image,PICTRectangle *rectangle)
{
- if (x > y)
- return(x);
- return(y);
+ rectangle->top=(short) ReadBlobMSBShort(image);
+ rectangle->left=(short) ReadBlobMSBShort(image);
+ rectangle->bottom=(short) ReadBlobMSBShort(image);
+ rectangle->right=(short) ReadBlobMSBShort(image);
+ if ((EOFBlob(image) != MagickFalse) ||
+ ((rectangle->bottom-rectangle->top) <= 0) ||
+ ((rectangle->right-rectangle->left) <= 0))
+ return(MagickFalse);
+ return(MagickTrue);
}
static Image *ReadPICTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
+#define ThrowPICTException(exception,message) \
+{ \
+ if (tile_image != (Image *) NULL) \
+ tile_image=DestroyImage(tile_image); \
+ if (read_info != (ImageInfo *) NULL) \
+ read_info=DestroyImageInfo(read_info); \
+ ThrowReaderException((exception),(message)); \
+}
+
char
- geometry[MaxTextExtent];
+ geometry[MagickPathExtent],
+ header_ole[4];
Image
- *image;
+ *image,
+ *tile_image;
+
+ ImageInfo
+ *read_info;
int
c,
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);
- image->depth=8;
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
/*
Read PICT header.
*/
+ read_info=(ImageInfo *) NULL;
+ tile_image=(Image *) NULL;
pixmap.bits_per_pixel=0;
pixmap.component_count=0;
- for (i=0; i < 512; i++)
- (void) ReadBlobByte(image); /* skip header */
+ /*
+ Skip header : 512 for standard PICT and 4, ie "PICT" for OLE2.
+ */
+ header_ole[0]=ReadBlobByte(image);
+ header_ole[1]=ReadBlobByte(image);
+ header_ole[2]=ReadBlobByte(image);
+ header_ole[3]=ReadBlobByte(image);
+ if (!((header_ole[0] == 0x50) && (header_ole[1] == 0x49) &&
+ (header_ole[2] == 0x43) && (header_ole[3] == 0x54 )))
+ for (i=0; i < 508; i++)
+ if (ReadBlobByte(image) == EOF)
+ break;
(void) ReadBlobMSBShort(image); /* skip picture size */
- ReadRectangle(image,frame);
+ if (ReadRectangle(image,&frame) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
while ((c=ReadBlobByte(image)) == 0) ;
if (c != 0x11)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- version=ReadBlobByte(image);
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ version=(ssize_t) ReadBlobByte(image);
if (version == 2)
{
c=ReadBlobByte(image);
if (c != 0xff)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
}
else
if (version != 1)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
if ((frame.left < 0) || (frame.right < 0) || (frame.top < 0) ||
(frame.bottom < 0) || (frame.left >= frame.right) ||
(frame.top >= frame.bottom))
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
/*
Create black canvas.
*/
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->depth=8;
+ image->columns=(size_t) (frame.right-frame.left);
+ image->rows=(size_t) (frame.bottom-frame.top);
+ image->resolution.x=DefaultResolution;
+ image->resolution.y=DefaultResolution;
image->units=UndefinedResolution;
+ if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
+ if (image->scene >= (image_info->scene+image_info->number_scenes-1))
+ {
+ (void) CloseBlob(image);
+ return(GetFirstImageInList(image));
+ }
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status != MagickFalse)
+ status=ResetImagePixels(image,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
/*
Interpret PICT opcodes.
*/
if ((version == 1) || ((TellBlob(image) % 2) != 0))
code=ReadBlobByte(image);
if (version == 2)
- code=(int) ReadBlobMSBShort(image);
+ code=ReadBlobMSBSignedShort(image);
+ if (code < 0)
+ break;
+ if (code == 0)
+ continue;
if (code > 0xa1)
{
if (image->debug != MagickFalse)
Clipping rectangle.
*/
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
if (length != 0x000a)
{
for (i=0; i < (ssize_t) (length-2); i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
break;
}
- ReadRectangle(image,frame);
+ if (ReadRectangle(image,&frame) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
if (((frame.left & 0x8000) != 0) || ((frame.top & 0x8000) != 0))
break;
- image->columns=1UL*(frame.right-frame.left);
- image->rows=1UL*(frame.bottom-frame.top);
- (void) SetImageBackgroundColor(image,exception);
+ image->columns=(size_t) (frame.right-frame.left);
+ image->rows=(size_t) (frame.bottom-frame.top);
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status != MagickFalse)
+ status=ResetImagePixels(image,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
break;
}
case 0x12:
/*
Skip pattern definition.
*/
- pattern=1L*ReadBlobMSBShort(image);
+ pattern=(ssize_t) ReadBlobMSBShort(image);
for (i=0; i < 8; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
if (pattern == 2)
{
for (i=0; i < 5; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
break;
}
if (pattern != 1)
- ThrowReaderException(CorruptImageError,"UnknownPatternType");
+ ThrowPICTException(CorruptImageError,"UnknownPatternType");
length=ReadBlobMSBShort(image);
- 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;
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
+ if (ReadRectangle(image,&frame) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ if (ReadPixmap(image,&pixmap) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ image->depth=(size_t) pixmap.component_size;
+ 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);
+ flags=(ssize_t) ReadBlobMSBShort(image);
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
for (i=0; i <= (ssize_t) length; i++)
(void) ReadBlobMSBLong(image);
- width=1UL*(frame.bottom-frame.top);
- height=1UL*(frame.right-frame.left);
+ width=(size_t) (frame.bottom-frame.top);
+ height=(size_t) (frame.right-frame.left);
if (pixmap.bits_per_pixel <= 8)
length&=0x7fff;
if (pixmap.bits_per_pixel == 16)
if (length < 8)
{
for (i=0; i < (ssize_t) (length*height); i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
}
else
- for (j=0; j < (int) height; j++)
+ for (i=0; i < (ssize_t) height; i++)
+ {
+ if (EOFBlob(image) != MagickFalse)
+ break;
if (length > 200)
- for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++)
- (void) ReadBlobByte(image);
+ {
+ for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++)
+ if (ReadBlobByte(image) == EOF)
+ break;
+ }
else
for (j=0; j < (ssize_t) ReadBlobByte(image); j++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
+ }
break;
}
case 0x1b:
Skip polygon or region.
*/
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
for (i=0; i < (ssize_t) (length-2); i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
break;
}
case 0x90:
case 0x9a:
case 0x9b:
{
- Image
- *tile_image;
-
PICTRectangle
source,
destination;
*/
bytes_per_line=0;
if ((code != 0x9a) && (code != 0x9b))
- bytes_per_line=1L*ReadBlobMSBShort(image);
+ bytes_per_line=(ssize_t) ReadBlobMSBShort(image);
else
{
(void) ReadBlobMSBShort(image);
(void) ReadBlobMSBShort(image);
(void) ReadBlobMSBShort(image);
}
- ReadRectangle(image,frame);
+ if (ReadRectangle(image,&frame) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
/*
Initialize tile image.
*/
- tile_image=CloneImage(image,1UL*(frame.right-frame.left),
- 1UL*(frame.bottom-frame.top),MagickTrue,exception);
+ tile_image=CloneImage(image,(size_t) (frame.right-frame.left),
+ (size_t) (frame.bottom-frame.top),MagickTrue,exception);
if (tile_image == (Image *) NULL)
- return((Image *) NULL);
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
if ((code == 0x9a) || (code == 0x9b) ||
((bytes_per_line & 0x8000) != 0))
{
- ReadPixmap(pixmap);
- 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;
+ if (ReadPixmap(image,&pixmap) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ tile_image->depth=(size_t) pixmap.component_size;
+ tile_image->alpha_trait=pixmap.component_count == 4 ?
+ BlendPixelTrait : UndefinedPixelTrait;
+ 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;
+ if (tile_image->alpha_trait != UndefinedPixelTrait)
+ (void) SetImageAlpha(tile_image,OpaqueAlpha,exception);
}
if ((code != 0x9a) && (code != 0x9b))
{
if ((bytes_per_line & 0x8000) != 0)
{
(void) ReadBlobMSBLong(image);
- flags=1L*ReadBlobMSBShort(image);
+ flags=(ssize_t) ReadBlobMSBShort(image);
tile_image->colors=1UL*ReadBlobMSBShort(image)+1;
}
status=AcquireImageColormap(tile_image,tile_image->colors,
exception);
if (status == MagickFalse)
- {
- tile_image=DestroyImage(tile_image);
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
- }
+ ThrowPICTException(ResourceLimitError,
+ "MemoryAllocationFailed");
if ((bytes_per_line & 0x8000) != 0)
{
for (i=0; i < (ssize_t) tile_image->colors; i++)
}
}
}
- ReadRectangle(image,source);
- ReadRectangle(image,destination);
+ if (EOFBlob(image) != MagickFalse)
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
+ if (ReadRectangle(image,&source) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ if (ReadRectangle(image,&destination) == MagickFalse)
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
(void) ReadBlobMSBShort(image);
if ((code == 0x91) || (code == 0x99) || (code == 0x9b))
{
Skip region.
*/
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
for (i=0; i < (ssize_t) (length-2); i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
}
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,(size_t) bytes_per_line,1,
+ &extent);
else
- pixels=DecodeImage(image,tile_image,1UL*bytes_per_line,1U*
- pixmap.bits_per_pixel,&extent);
+ pixels=DecodeImage(image,tile_image,(size_t) bytes_per_line,
+ (unsigned int) pixmap.bits_per_pixel,&extent);
if (pixels == (unsigned char *) NULL)
- {
- tile_image=DestroyImage(tile_image);
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
- }
+ ThrowPICTException(CorruptImageError,"UnableToUncompressImage");
/*
Convert PICT tile image to pixel packets.
*/
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
if (p > (pixels+extent+image->columns))
- ThrowReaderException(CorruptImageError,"NotEnoughPixelData");
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ ThrowPICTException(CorruptImageError,"NotEnoughPixelData");
+ }
q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1,
exception);
if (q == (Quantum *) NULL)
{
if (tile_image->storage_class == PseudoClass)
{
- index=ConstrainColormapIndex(tile_image,*p);
+ index=(Quantum) ConstrainColormapIndex(tile_image,(ssize_t)
+ *p,exception);
SetPixelIndex(tile_image,index,q);
SetPixelRed(tile_image,
tile_image->colormap[(ssize_t) index].red,q);
{
if (pixmap.bits_per_pixel == 16)
{
- i=(*p++);
- j=(*p);
+ i=(ssize_t) (*p++);
+ j=(size_t) (*p);
SetPixelRed(tile_image,ScaleCharToQuantum(
(unsigned char) ((i & 0x7c) << 1)),q);
SetPixelGreen(tile_image,ScaleCharToQuantum(
(unsigned char) ((j & 0x1f) << 3)),q);
}
else
- if (tile_image->matte == MagickFalse)
+ if (tile_image->alpha_trait == UndefinedPixelTrait)
{
if (p > (pixels+extent+2*image->columns))
- ThrowReaderException(CorruptImageError,
+ ThrowPICTException(CorruptImageError,
"NotEnoughPixelData");
SetPixelRed(tile_image,ScaleCharToQuantum(*p),q);
SetPixelGreen(tile_image,ScaleCharToQuantum(
else
{
if (p > (pixels+extent+3*image->columns))
- ThrowReaderException(CorruptImageError,
+ ThrowPICTException(CorruptImageError,
"NotEnoughPixelData");
SetPixelAlpha(tile_image,ScaleCharToQuantum(*p),q);
SetPixelRed(tile_image,ScaleCharToQuantum(
if (p < pixels)
break;
}
- status=SetImageProgress(image,LoadImageTag,y,tile_image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ tile_image->rows);
if (status == MagickFalse)
break;
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
- if (jpeg == MagickFalse)
+ if ((jpeg == MagickFalse) && (EOFBlob(image) == MagickFalse))
if ((code == 0x9a) || (code == 0x9b) ||
((bytes_per_line & 0x8000) != 0))
- (void) CompositeImage(image,CopyCompositeOp,tile_image,
- destination.left,destination.top,exception);
+ (void) CompositeImage(image,tile_image,CopyCompositeOp,
+ MagickTrue,(ssize_t) destination.left,(ssize_t)
+ destination.top,exception);
tile_image=DestroyImage(tile_image);
break;
}
*/
type=ReadBlobMSBShort(image);
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
if (length == 0)
break;
(void) ReadBlobMSBLong(image);
- length-=4;
+ length-=MagickMin(length,4);
if (length == 0)
break;
info=(unsigned char *) AcquireQuantumMemory(length,sizeof(*info));
if (info == (unsigned char *) NULL)
break;
count=ReadBlob(image,length,info);
- (void) count;
+ if (count != (ssize_t) length)
+ {
+ info=(unsigned char *) RelinquishMagickMemory(info);
+ ThrowPICTException(ResourceLimitError,"UnableToReadImageData");
+ }
switch (type)
{
case 0xe0:
{
- if (length == 0)
- break;
profile=BlobToStringInfo((const void *) NULL,length);
SetStringInfoDatum(profile,info);
status=SetImageProfile(image,"icc",profile,exception);
profile=DestroyStringInfo(profile);
if (status == MagickFalse)
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ {
+ info=(unsigned char *) RelinquishMagickMemory(info);
+ ThrowPICTException(ResourceLimitError,
+ "MemoryAllocationFailed");
+ }
break;
}
case 0x1f2:
{
- if (length == 0)
- break;
profile=BlobToStringInfo((const void *) NULL,length);
SetStringInfoDatum(profile,info);
status=SetImageProfile(image,"iptc",profile,exception);
if (status == MagickFalse)
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ {
+ info=(unsigned char *) RelinquishMagickMemory(info);
+ ThrowPICTException(ResourceLimitError,
+ "MemoryAllocationFailed");
+ }
profile=DestroyStringInfo(profile);
break;
}
(void) ReadBlobMSBShort(image);
else
for (i=0; i < (ssize_t) codes[code].length; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
}
}
}
Skip header.
*/
for (i=0; i < 24; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
continue;
}
if (((code >= 0xb0) && (code <= 0xcf)) ||
continue;
if (code == 0x8200)
{
+ char
+ filename[MaxTextExtent];
+
FILE
*file;
- Image
- *tile_image;
-
- ImageInfo
- *read_info;
-
int
unique_file;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
file=(FILE *) NULL;
- unique_file=AcquireUniqueFileResource(read_info->filename);
+ unique_file=AcquireUniqueFileResource(filename);
+ (void) FormatLocaleString(read_info->filename,MaxTextExtent,"jpeg:%s",
+ filename);
if (unique_file != -1)
file=fdopen(unique_file,"wb");
if ((unique_file == -1) || (file == (FILE *) NULL))
{
+ (void) RelinquishUniqueFileResource(read_info->filename);
(void) CopyMagickString(image->filename,read_info->filename,
- MaxTextExtent);
- ThrowFileException(exception,FileOpenError,
- "UnableToCreateTemporaryFile",image->filename);
- image=DestroyImageList(image);
- return((Image *) NULL);
+ MagickPathExtent);
+ ThrowPICTException(FileOpenError,"UnableToCreateTemporaryFile");
}
length=ReadBlobMSBLong(image);
- for (i=0; i < 6; i++)
- (void) ReadBlobMSBLong(image);
- ReadRectangle(image,frame);
- for (i=0; i < 122; i++)
- (void) ReadBlobByte(image);
- for (i=0; i < (ssize_t) (length-154); i++)
- {
- c=ReadBlobByte(image);
- (void) fputc(c,file);
- }
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
+ if (length > 154)
+ {
+ for (i=0; i < 6; i++)
+ (void) ReadBlobMSBLong(image);
+ if (ReadRectangle(image,&frame) == MagickFalse)
+ {
+ (void) fclose(file);
+ (void) RelinquishUniqueFileResource(read_info->filename);
+ ThrowPICTException(CorruptImageError,"ImproperImageHeader");
+ }
+ for (i=0; i < 122; i++)
+ if (ReadBlobByte(image) == EOF)
+ break;
+ for (i=0; i < (ssize_t) (length-154); i++)
+ {
+ c=ReadBlobByte(image);
+ if (c == EOF)
+ break;
+ if (fputc(c,file) != c)
+ break;
+ }
+ }
(void) fclose(file);
+ (void) close(unique_file);
tile_image=ReadImage(read_info,exception);
- (void) RelinquishUniqueFileResource(read_info->filename);
+ (void) RelinquishUniqueFileResource(filename);
read_info=DestroyImageInfo(read_info);
if (tile_image == (Image *) NULL)
continue;
- (void) FormatLocaleString(geometry,MaxTextExtent,"%.20gx%.20g",
+ (void) FormatLocaleString(geometry,MagickPathExtent,"%.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),exception);
- if (IsRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,tile_image->colorspace,
- exception);
- (void) CompositeImage(image,CopyCompositeOp,tile_image,frame.left,
- frame.right,exception);
+ (void) TransformImageColorspace(image,tile_image->colorspace,exception);
+ (void) CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue,
+ (ssize_t) frame.left,(ssize_t) frame.right,exception);
image->compression=tile_image->compression;
tile_image=DestroyImage(tile_image);
continue;
Skip reserved.
*/
length=ReadBlobMSBShort(image);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
for (i=0; i < (ssize_t) length; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
continue;
}
if ((code >= 0x100) && (code <= 0x7fff))
Skip reserved.
*/
length=(size_t) ((code >> 7) & 0xff);
+ if (length > GetBlobSize(image))
+ ThrowPICTException(CorruptImageError,
+ "InsufficientImageDataInFile");
for (i=0; i < (ssize_t) length; i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ break;
continue;
}
}
MagickInfo
*entry;
- entry=SetMagickInfo("PCT");
+ entry=AcquireMagickInfo("PICT","PCT","Apple Macintosh QuickDraw/PICT");
entry->decoder=(DecodeImageHandler *) ReadPICTImage;
entry->encoder=(EncodeImageHandler *) WritePICTImage;
- entry->adjoin=MagickFalse;
- entry->seekable_stream=MagickTrue;
- entry->description=ConstantString("Apple Macintosh QuickDraw/PICT");
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags|=CoderEncoderSeekableStreamFlag;
entry->magick=(IsImageFormatHandler *) IsPICT;
- entry->module=ConstantString("PICT");
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("PICT");
+ entry=AcquireMagickInfo("PICT","PICT","Apple Macintosh QuickDraw/PICT");
entry->decoder=(DecodeImageHandler *) ReadPICTImage;
entry->encoder=(EncodeImageHandler *) WritePICTImage;
- entry->adjoin=MagickFalse;
- entry->seekable_stream=MagickTrue;
- entry->description=ConstantString("Apple Macintosh QuickDraw/PICT");
+ entry->flags^=CoderAdjoinFlag;
+ entry->flags|=CoderEncoderSeekableStreamFlag;
entry->magick=(IsImageFormatHandler *) IsPICT;
- entry->module=ConstantString("PICT");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
size_t
bytes_per_line,
count,
+ row_bytes,
storage_class;
ssize_t
unsigned short
base_address,
- row_bytes,
transfer_mode;
/*
Open output image file.
*/
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);
if ((image->columns > 65535L) || (image->rows > 65535L))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
- if (IsRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,RGBColorspace,exception);
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
/*
Initialize image info.
*/
source_rectangle=size_rectangle;
destination_rectangle=size_rectangle;
base_address=0xff;
- row_bytes=(unsigned short) (image->columns | 0x8000);
+ row_bytes=image->columns;
bounds.top=0;
bounds.left=0;
bounds.bottom=(short) image->rows;
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)
storage_class=DirectClass;
- if ((storage_class == DirectClass) || (image->matte != MagickFalse))
+ if (storage_class == DirectClass)
{
- pixmap.component_count=image->matte ? 4 : 3;
+ pixmap.component_count=image->alpha_trait != UndefinedPixelTrait ? 4 : 3;
pixmap.pixel_type=16;
pixmap.bits_per_pixel=32;
pixmap.pack_type=0x04;
transfer_mode=0x40;
- row_bytes=(unsigned short) ((4*image->columns) | 0x8000);
+ row_bytes=4*image->columns;
}
/*
Allocate memory.
*/
- bytes_per_line=image->columns;
- if ((storage_class == DirectClass) || (image->matte != MagickFalse))
- bytes_per_line*=image->matte ? 4 : 3;
+ bytes_per_line=image->columns | 0x8000;
+ if (storage_class == DirectClass)
+ bytes_per_line*=image->alpha_trait != UndefinedPixelTrait ? 4 : 3;
buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer));
packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t)
- (row_bytes+MaxCount),sizeof(*packed_scanline));
+ (row_bytes+2*MaxCount),sizeof(*packed_scanline));
scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline));
if ((buffer == (unsigned char *) NULL) ||
(packed_scanline == (unsigned char *) NULL) ||
(scanline == (unsigned char *) NULL))
- ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- (void) ResetMagickMemory(scanline,0,row_bytes);
- (void) ResetMagickMemory(packed_scanline,0,(size_t) (row_bytes+MaxCount));
+ {
+ if (scanline != (unsigned char *) NULL)
+ scanline=(unsigned char *) RelinquishMagickMemory(scanline);
+ if (packed_scanline != (unsigned char *) NULL)
+ packed_scanline=(unsigned char *) RelinquishMagickMemory(
+ packed_scanline);
+ if (buffer != (unsigned char *) NULL)
+ buffer=(unsigned char *) RelinquishMagickMemory(buffer);
+ ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ }
+ (void) memset(scanline,0,row_bytes);
+ (void) memset(packed_scanline,0,(size_t) (row_bytes+2*MaxCount));
/*
Write header, header size, size bounding box, version, and reserved.
*/
- (void) ResetMagickMemory(buffer,0,PictInfoSize);
+ (void) memset(buffer,0,PictInfoSize);
(void) WriteBlob(image,PictInfoSize,buffer);
(void) WriteBlobMSBShort(image,0);
(void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top);
(void) WriteBlobMSBShort(image,PictVersion);
(void) WriteBlobMSBShort(image,0x02ff); /* version #2 */
(void) WriteBlobMSBShort(image,PictInfoOp);
- (void) WriteBlobMSBLong(image,0xFFFE0000UL);
+ (void) WriteBlobMSBLong(image,0xFFFE0000U);
/*
Write full size of the file, resolution, frame bounding box, and reserved.
*/
(void) WriteBlobMSBShort(image,0xe0);
(void) WriteBlobMSBShort(image,(unsigned short)
(GetStringInfoLength(profile)+4));
- (void) WriteBlobMSBLong(image,0x00000000UL);
+ (void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlob(image,GetStringInfoLength(profile),
GetStringInfoDatum(profile));
(void) WriteBlobMSBShort(image,0xa1);
(void) WriteBlobMSBShort(image,0xe0);
(void) WriteBlobMSBShort(image,4);
- (void) WriteBlobMSBLong(image,0x00000002UL);
+ (void) WriteBlobMSBLong(image,0x00000002U);
}
/*
Write crop region opcode and crop bounding box.
return(MagickFalse);
}
jpeg_info=CloneImageInfo(image_info);
- (void) CopyMagickString(jpeg_info->magick,"JPEG",MaxTextExtent);
+ (void) CopyMagickString(jpeg_info->magick,"JPEG",MagickPathExtent);
length=0;
blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length,
exception);
(void) WriteBlobMSBShort(image,PictJPEGOp);
(void) WriteBlobMSBLong(image,(unsigned int) length+154);
(void) WriteBlobMSBShort(image,0x0000);
- (void) WriteBlobMSBLong(image,0x00010000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00010000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x40000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00400000UL);
+ (void) WriteBlobMSBLong(image,0x00010000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00010000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x40000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00400000U);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) image->rows);
(void) WriteBlobMSBShort(image,(unsigned short) image->columns);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,768);
(void) WriteBlobMSBShort(image,0x0000);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00566A70UL);
- (void) WriteBlobMSBLong(image,0x65670000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000001UL);
- (void) WriteBlobMSBLong(image,0x00016170UL);
- (void) WriteBlobMSBLong(image,0x706C0000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00566A70U);
+ (void) WriteBlobMSBLong(image,0x65670000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000001U);
+ (void) WriteBlobMSBLong(image,0x00016170U);
+ (void) WriteBlobMSBLong(image,0x706C0000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBShort(image,768);
(void) WriteBlobMSBShort(image,(unsigned short) image->columns);
(void) WriteBlobMSBShort(image,(unsigned short) image->rows);
(void) WriteBlobMSBShort(image,(unsigned short) x_resolution);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) y_resolution);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x87AC0001UL);
- (void) WriteBlobMSBLong(image,0x0B466F74UL);
- (void) WriteBlobMSBLong(image,0x6F202D20UL);
- (void) WriteBlobMSBLong(image,0x4A504547UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x00000000UL);
- (void) WriteBlobMSBLong(image,0x0018FFFFUL);
+ (void) WriteBlobMSBShort(image,0x0000);
+ (void) WriteBlobMSBLong(image,length);
+ (void) WriteBlobMSBShort(image,0x0001);
+ (void) WriteBlobMSBLong(image,0x0B466F74U);
+ (void) WriteBlobMSBLong(image,0x6F202D20U);
+ (void) WriteBlobMSBLong(image,0x4A504547U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x00000000U);
+ (void) WriteBlobMSBLong(image,0x0018FFFFU);
(void) WriteBlob(image,length,blob);
if ((length & 0x01) != 0)
(void) WriteBlobByte(image,'\0');
else
{
(void) WriteBlobMSBShort(image,PictPixmapOp);
- (void) WriteBlobMSBLong(image,(size_t) base_address);
+ (void) WriteBlobMSBLong(image,(unsigned int) base_address);
}
(void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000));
(void) WriteBlobMSBShort(image,(unsigned short) bounds.top);
Write picture data.
*/
count=0;
- if ((storage_class == PseudoClass) && (image->matte == MagickFalse))
+ if (storage_class == PseudoClass)
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
else
if (image_info->compression == JPEGCompression)
{
- (void) ResetMagickMemory(scanline,0,row_bytes);
+ (void) memset(scanline,0,row_bytes);
for (y=0; y < (ssize_t) image->rows; y++)
count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
packed_scanline);
red=scanline;
green=scanline+image->columns;
blue=scanline+2*image->columns;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait != UndefinedPixelTrait)
{
opacity=scanline;
red=scanline+image->columns;
*red++=ScaleQuantumToChar(GetPixelRed(image,p));
*green++=ScaleQuantumToChar(GetPixelGreen(image,p));
*blue++=ScaleQuantumToChar(GetPixelBlue(image,p));
- if (image->matte != MagickFalse)
+ if (image->alpha_trait != UndefinedPixelTrait)
*opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p)));
p+=GetPixelChannels(image);
}
- count+=EncodeImage(image,scanline,bytes_per_line & 0x7FFF,
- packed_scanline);
+ count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,