summaryrefslogtreecommitdiff
path: root/coders/pcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'coders/pcd.c')
-rw-r--r--coders/pcd.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/coders/pcd.c b/coders/pcd.c
index 38bd402c5..4a97ee1d7 100644
--- a/coders/pcd.c
+++ b/coders/pcd.c
@@ -195,7 +195,7 @@ static MagickBooleanType DecodeImage(Image *image,unsigned char *luma,
pcd_table[i]=(PCDTable *) NULL;
pcd_length[i]=0;
}
- for (i=0; i < (image->columns > 1536 ? 3 : 1); i++)
+ for (i=0; i < (ssize_t) (image->columns > 1536 ? 3 : 1); i++)
{
PCDGetBits(8);
length=(sum & 0xff)+1;
@@ -289,7 +289,7 @@ static MagickBooleanType DecodeImage(Image *image,unsigned char *luma,
}
default:
{
- for (i=0; i < (image->columns > 1536 ? 3 : 1); i++)
+ for (i=0; i < (ssize_t) (image->columns > 1536 ? 3 : 1); i++)
pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]);
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
ThrowBinaryException(CorruptImageError,"CorruptImage",
@@ -327,7 +327,7 @@ static MagickBooleanType DecodeImage(Image *image,unsigned char *luma,
/*
Relinquish resources.
*/
- for (i=0; i < (image->columns > 1536 ? 3 : 1); i++)
+ for (i=0; i < (ssize_t) (image->columns > 1536 ? 3 : 1); i++)
pcd_table[i]=(PCDTable *) RelinquishMagickMemory(pcd_table[i]);
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
return(MagickTrue);
@@ -484,12 +484,8 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
{ \
if (header != (unsigned char *) NULL) \
header=(unsigned char *) RelinquishMagickMemory(header); \
- if (luma != (unsigned char *) NULL) \
- luma=(unsigned char *) RelinquishMagickMemory(luma); \
- if (chroma2 != (unsigned char *) NULL) \
- chroma2=(unsigned char *) RelinquishMagickMemory(chroma2); \
- if (chroma1 != (unsigned char *) NULL) \
- chroma1=(unsigned char *) RelinquishMagickMemory(chroma1); \
+ if (pixel_info != (MemoryInfo *) NULL) \
+ pixel_info=RelinquishVirtualMemory(pixel_info); \
ThrowReaderException((exception),(message)); \
}
@@ -502,8 +498,8 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
MagickOffsetType
offset;
- MagickSizeType
- number_pixels;
+ MemoryInfo
+ *pixel_info;
ssize_t
i,
@@ -520,6 +516,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
size_t
height,
number_images,
+ number_pixels,
rotate,
scene,
width;
@@ -560,9 +557,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
header=(unsigned char *) AcquireQuantumMemory(0x800,3UL*sizeof(*header));
if (header == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- chroma1=(unsigned char *) NULL;
- chroma2=(unsigned char *) NULL;
- luma=(unsigned char *) NULL;
+ pixel_info=(MemoryInfo *) NULL;
count=ReadBlob(image,3*0x800,header);
if (count != (3*0x800))
ThrowPCDException(CorruptImageError,"ImproperImageHeader");
@@ -623,24 +618,15 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Allocate luma and chroma memory.
*/
- number_pixels=(MagickSizeType) image->columns*image->rows;
- if (number_pixels != (size_t) number_pixels)
+ pixel_info=AcquireVirtualMemory(image->columns+1UL,30*image->rows*
+ sizeof(*luma));
+ if (pixel_info == (MemoryInfo *) NULL)
ThrowPCDException(ResourceLimitError,"MemoryAllocationFailed");
- chroma1=(unsigned char *) AcquireQuantumMemory(image->columns+1UL,image->rows*
- 10*sizeof(*chroma1));
- chroma2=(unsigned char *) AcquireQuantumMemory(image->columns+1UL,image->rows*
- 10*sizeof(*chroma2));
- luma=(unsigned char *) AcquireQuantumMemory(image->columns+1UL,image->rows*
- 10*sizeof(*luma));
- if ((chroma1 == (unsigned char *) NULL) ||
- (chroma2 == (unsigned char *) NULL) || (luma == (unsigned char *) NULL))
- ThrowPCDException(ResourceLimitError,"MemoryAllocationFailed");
- (void) memset(chroma1,0,(image->columns+1UL)*image->rows*
- 10*sizeof(*chroma1));
- (void) memset(chroma2,0,(image->columns+1UL)*image->rows*
- 10*sizeof(*chroma2));
- (void) memset(luma,0,(image->columns+1UL)*image->rows*
- 10*sizeof(*luma));
+ number_pixels=(image->columns+1UL)*10*image->rows*sizeof(*luma);
+ luma=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
+ chroma1=(unsigned char *) GetVirtualMemoryBlob(pixel_info)+number_pixels;
+ chroma2=(unsigned char *) GetVirtualMemoryBlob(pixel_info)+2*number_pixels;
+ (void) memset(luma,0,3*number_pixels);
/*
Advance to image data.
*/
@@ -745,9 +731,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
break;
}
}
- chroma2=(unsigned char *) RelinquishMagickMemory(chroma2);
- chroma1=(unsigned char *) RelinquishMagickMemory(chroma1);
- luma=(unsigned char *) RelinquishMagickMemory(luma);
+ pixel_info=RelinquishVirtualMemory(pixel_info);
if (status == MagickFalse)
return(DestroyImageList(image));
return(OverviewImage(image_info,GetFirstImageInList(image),exception));
@@ -837,9 +821,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
break;
}
}
- chroma2=(unsigned char *) RelinquishMagickMemory(chroma2);
- chroma1=(unsigned char *) RelinquishMagickMemory(chroma1);
- luma=(unsigned char *) RelinquishMagickMemory(luma);
+ pixel_info=RelinquishVirtualMemory(pixel_info);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
@@ -1103,7 +1085,8 @@ static MagickBooleanType WritePCDTile(Image *image,const char *page_geometry,
GetPixelBlue(tile_image,q)));
q+=GetPixelChannels(tile_image);
}
- status=SetImageProgress(image,SaveImageTag,y,tile_image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ tile_image->rows);
if (status == MagickFalse)
break;
}