% July 1992 %
% %
% %
-% 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 declarations.
*/
#include "magick/studio.h"
+#include "magick/attribute.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/colormap-private.h"
#include "magick/color-private.h"
+#include "magick/colormap.h"
#include "magick/colorspace.h"
#include "magick/constitute.h"
#include "magick/exception.h"
attributes,
version;
- unsigned long
+ size_t
create_time,
modify_time,
archive_time,
type[4], /* database type identifier "vIMG" */
id[4]; /* database creator identifier "View" */
- unsigned long
+ size_t
seed,
next_record;
version,
type;
- unsigned long
+ size_t
reserved_1,
note;
x_last,
y_last;
- unsigned long
+ size_t
reserved_2;
short int
IndexPacket
index;
- long
+ ssize_t
img_offset, /* TS */
comment_offset = 0,
y;
register IndexPacket
*indexes;
- register long
+ register ssize_t
x;
register PixelPacket
unsigned char
*pixels;
- unsigned long
- num_pad_bytes, /* TS */
+ size_t
bits_per_pixel,
+ num_pad_bytes, /* TS */
+ one,
packets;
/*
/*
Read record header.
*/
- img_offset=(long) ReadBlobMSBLong(image); /* TS */
+ img_offset=(int) ReadBlobMSBLong(image); /* TS */
attributes=(unsigned char) ReadBlobByte(image);
count=ReadBlob(image,3,(unsigned char *) tag);
if (count != 3 || memcmp(tag,"\x6f\x80\x00",3) != 0)
if (pdb_info.number_records > 1)
{
- comment_offset=(long) ReadBlobMSBLong(image);
+ comment_offset=(int) ReadBlobMSBLong(image);
attributes=(unsigned char) ReadBlobByte(image);
count=ReadBlob(image,3,(unsigned char *) tag);
if (count != 3 || memcmp(tag,"\x6f\x80\x01",3) != 0)
ThrowReaderException(CorruptImageError,"CorruptImage");
}
- num_pad_bytes = (unsigned long) (img_offset - TellBlob( image ));
+ num_pad_bytes = (size_t) (img_offset - TellBlob( image ));
while (num_pad_bytes--) ReadBlobByte( image );
/*
Read image header.
/*
Initialize image structure.
*/
- image->columns=(unsigned long) pdb_image.width;
- image->rows=(unsigned long) pdb_image.height;
+ image->columns=(size_t) pdb_image.width;
+ image->rows=(size_t) pdb_image.height;
image->depth=8;
image->storage_class=PseudoClass;
bits_per_pixel=pdb_image.type == 0 ? 2UL : pdb_image.type == 2 ? 4UL : 1UL;
- if (AcquireImageColormap(image,1 << bits_per_pixel) == MagickFalse)
+ one=1;
+ if (AcquireImageColormap(image,one << bits_per_pixel) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (image_info->ping != MagickFalse)
{
/*
Read 1-bit PDB image.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
- for (x=0; x < ((long) image->columns-7); x+=8)
+ for (x=0; x < ((ssize_t) image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
{
index=(IndexPacket) (*p & (0x80 >> bit) ? 0x00 : 0x01);
indexes[x+bit]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
}
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
/*
Read 2-bit PDB image.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
- for (x=0; x < (long) image->columns; x+=4)
+ for (x=0; x < (ssize_t) image->columns; x+=4)
{
index=ConstrainColormapIndex(image,3UL-((*p >> 6) & 0x03));
indexes[x]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
index=ConstrainColormapIndex(image,3UL-((*p >> 4) & 0x03));
indexes[x+1]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
index=ConstrainColormapIndex(image,3UL-((*p >> 2) & 0x03));
indexes[x+2]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
index=ConstrainColormapIndex(image,3UL-((*p) & 0x03));
indexes[x+3]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
/*
Read 4-bit PDB image.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
- for (x=0; x < (long) image->columns; x+=2)
+ for (x=0; x < (ssize_t) image->columns; x+=2)
{
index=ConstrainColormapIndex(image,15UL-((*p >> 4) & 0x0f));
indexes[x]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
index=ConstrainColormapIndex(image,15UL-((*p) & 0x0f));
indexes[x+1]=index;
- *q++=image->colormap[(long) index];
+ *q++=image->colormap[(ssize_t) index];
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
register char
*p;
- unsigned long
+ size_t
length;
- num_pad_bytes = (unsigned long) (comment_offset - TellBlob( image ));
+ num_pad_bytes = (size_t) (comment_offset - TellBlob( image ));
while (num_pad_bytes--) ReadBlobByte( image );
/*
%
% The format of the RegisterPDBImage method is:
%
-% unsigned long RegisterPDBImage(void)
+% size_t RegisterPDBImage(void)
%
*/
-ModuleExport unsigned long RegisterPDBImage(void)
+ModuleExport size_t RegisterPDBImage(void)
{
MagickInfo
*entry;
*/
static unsigned char *EncodeRLE(unsigned char *destination,
- unsigned char *source,unsigned long literal,unsigned long repeat)
+ unsigned char *source,size_t literal,size_t repeat)
{
if (literal > 0)
*destination++=(unsigned char) (literal-1);
int
bits;
- long
+ ssize_t
y;
MagickBooleanType
register const PixelPacket
*p;
- register long
+ register ssize_t
x;
register unsigned char
*runlength,
*scanline;
- unsigned long
+ size_t
bits_per_pixel,
literal,
packets,
(void) WriteBlob(image,32,(unsigned char *) pdb_info.name);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_info.attributes);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_info.version);
- (void) WriteBlobMSBLong(image,pdb_info.create_time);
- (void) WriteBlobMSBLong(image,pdb_info.modify_time);
- (void) WriteBlobMSBLong(image,pdb_info.archive_time);
- (void) WriteBlobMSBLong(image,pdb_info.modify_number);
- (void) WriteBlobMSBLong(image,pdb_info.application_info);
- (void) WriteBlobMSBLong(image,pdb_info.sort_info);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.create_time);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.modify_time);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.archive_time);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.modify_number);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.application_info);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.sort_info);
(void) WriteBlob(image,4,(unsigned char *) pdb_info.type);
(void) WriteBlob(image,4,(unsigned char *) pdb_info.id);
- (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.seed);
- (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.next_record);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.seed);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_info.next_record);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_info.number_records);
(void) CopyMagickString(pdb_image.name,pdb_info.name,32);
pdb_image.version=1; /* RLE Compressed */
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- bits=8/(long) bits_per_pixel-1; /* start at most significant bits */
+ bits=8/(int) bits_per_pixel-1; /* start at most significant bits */
literal=0;
repeat=0;
q=runlength;
buffer[0]=0x00;
- 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)
GrayQuantum,scanline,&image->exception);
for (x=0; x < pdb_image.width; x++)
{
- if (x < (long) image->columns)
+ if (x < (ssize_t) image->columns)
buffer[literal+repeat]|=(0xff-scanline[x*packet_size]) >>
(8-bits_per_pixel) << bits*bits_per_pixel;
bits--;
literal-=0x80;
}
}
- bits=8/(long) bits_per_pixel-1;
+ bits=8/(int) bits_per_pixel-1;
buffer[literal+repeat]=0x00;
}
}
- status=SetImageProgress(image,SaveImageTag,y,image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
/*
Write the Image record header.
*/
- (void) WriteBlobMSBLong(image,(unsigned long)
+ (void) WriteBlobMSBLong(image,(unsigned int)
(TellBlob(image)+8*pdb_info.number_records));
(void) WriteBlobByte(image,0x40);
(void) WriteBlobByte(image,0x6f);
/*
Write the comment record header.
*/
- (void) WriteBlobMSBLong(image,(unsigned long) (TellBlob(image)+8+58+q-
+ (void) WriteBlobMSBLong(image,(unsigned int) (TellBlob(image)+8+58+q-
runlength));
(void) WriteBlobByte(image,0x40);
(void) WriteBlobByte(image,0x6f);
(void) WriteBlob(image,32,(unsigned char *) pdb_image.name);
(void) WriteBlobByte(image,(unsigned char) pdb_image.version);
(void) WriteBlobByte(image,(unsigned char) pdb_image.type);
- (void) WriteBlobMSBLong(image,pdb_image.reserved_1);
- (void) WriteBlobMSBLong(image,pdb_image.note);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.reserved_1);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.note);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_image.x_last);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_image.y_last);
- (void) WriteBlobMSBLong(image,pdb_image.reserved_2);
+ (void) WriteBlobMSBLong(image,(unsigned int) pdb_image.reserved_2);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_image.x_anchor);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_image.y_anchor);
(void) WriteBlobMSBShort(image,(unsigned short) pdb_image.width);