%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
- 20071202 TS * rewrote RLE decoder - old version could cause buffer overflows
- * failure of RLE decoding now thows error RLEDecoderError
- * fixed bug in RLE decoding - now all rows are decoded, not just
- the first one
- * fixed bug in reader - record offsets now handled correctly
- * fixed bug in reader - only bits 0..2 indicate compression type
- * in writer: now using image color count instead of depth
+% 20071202 TS * rewrote RLE decoder - old version could cause buffer overflows
+% * failure of RLE decoding now thows error RLEDecoderError
+% * fixed bug in RLE decoding - now all rows are decoded, not just
+% the first one
+% * fixed bug in reader - record offsets now handled correctly
+% * fixed bug in reader - only bits 0..2 indicate compression type
+% * in writer: now using image color count instead of depth
*/
\f
/*
static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
unsigned char
- attributes, /* TS */
+ attributes,
tag[3];
Image
size_t
bits_per_pixel,
- num_pad_bytes, /* TS */
+ num_pad_bytes,
one,
packets;
ssize_t
count,
- img_offset, /* TS */
+ img_offset,
comment_offset = 0,
y;
/*
Read record header.
*/
- img_offset=(int) ReadBlobMSBLong(image); /* TS */
+ img_offset=(ssize_t) ((int) ReadBlobMSBLong(image));
attributes=(unsigned char) ReadBlobByte(image);
(void) attributes;
count=ReadBlob(image,3,(unsigned char *) tag);
ThrowReaderException(CorruptImageError,"CorruptImage");
if (pdb_info.number_records > 1)
{
- comment_offset=(int) ReadBlobMSBLong(image);
+ comment_offset=(ssize_t) ((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)
*/
count=ReadBlob(image,32,(unsigned char *) pdb_image.name);
pdb_image.version=ReadBlobByte(image);
- pdb_image.type=ReadBlobByte(image);
+ pdb_image.type=(unsigned char) ((int) ReadBlobByte(image));
pdb_image.reserved_1=ReadBlobMSBLong(image);
pdb_image.note=ReadBlobMSBLong(image);
pdb_image.x_last=(short) ReadBlobMSBShort(image);
if (pixels == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- switch (pdb_image.version & 7) /* TS */
+ switch (pdb_image.version & 0x07)
{
case 0:
{
{
image->compression=RLECompression;
if (!DecodeImage(image, pixels, packets * image -> rows))
- ThrowReaderException( CorruptImageError, "RLEDecoderError" ); /* TS */
+ ThrowReaderException( CorruptImageError, "RLEDecoderError" );
break;
}
default:
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
- if (pdb_info.number_records > 1) /* TS */
+ if (pdb_info.number_records > 1)
{
char
*comment;
if (status == MagickFalse)
return(status);
(void) TransformImageColorspace(image,sRGBColorspace,exception);
- if (image -> colors <= 2 || GetImageType( image, exception ) == BilevelType) { /* TS */
- bits_per_pixel = 1;
- } else if (image -> colors <= 4) {
- bits_per_pixel = 2;
- } else if (image -> colors <= 8) {
- bits_per_pixel = 3;
+ if ((image->colors <= 2) ||
+ (GetImageType(image,exception ) == BilevelType)) {
+ bits_per_pixel=1;
+ } else if (image->colors <= 4) {
+ bits_per_pixel=2;
+ } else if (image->colors <= 8) {
+ bits_per_pixel=3;
} else {
- bits_per_pixel = 4;
+ bits_per_pixel=4;
}
-
(void) ResetMagickMemory(pdb_info.name,0,32);
(void) CopyMagickString(pdb_info.name,image_info->filename,32);
pdb_info.attributes=0;
if (image->columns % 16)
pdb_image.width=(short) (16*(image->columns/16+1));
pdb_image.height=(short) image->rows;
- packets=(bits_per_pixel*image->columns/8)*image->rows;
+ packets=(bits_per_pixel*image->columns/8+4)*image->rows;
runlength=(unsigned char *) AcquireQuantumMemory(2UL*packets,
sizeof(*runlength));
if (runlength == (unsigned char *) NULL)
break;
(void) ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
GrayQuantum,scanline,exception);
- for (x=0; x < pdb_image.width; x++)
+ for (x=0; x < (ssize_t) pdb_image.width; x++)
{
if (x < (ssize_t) image->columns)
buffer[literal+repeat]|=(0xff-scanline[x*packet_size]) >>
}
}
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
- image->rows);
+ image->rows);
if (status == MagickFalse)
break;
}