% o exception: return any errors or warnings in this structure.
%
*/
+
static Image *OverviewImage(const ImageInfo *image_info,Image *image,
ExceptionInfo *exception)
{
static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
+#define ThrowPCDException(exception,message) \
+{ \
+ 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); \
+ ThrowReaderException((exception),(message)); \
+}
+
Image
*image;
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;
count=ReadBlob(image,3*0x800,header);
if (count != (3*0x800))
- {
- header=(unsigned char *) RelinquishMagickMemory(header);
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- }
+ ThrowPCDException(CorruptImageError,"ImproperImageHeader");
overview=LocaleNCompare((char *) header,"PCD_OPA",7) == 0;
if ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && (overview == 0))
- {
- header=(unsigned char *) RelinquishMagickMemory(header);
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- }
+ ThrowPCDException(CorruptImageError,"ImproperImageHeader");
rotate=header[0x0e02] & 0x03;
- number_images=(header[10] << 8) | header[11];
+ number_images=((header[10] << 8) | header[11]) & 0xffff;
header=(unsigned char *) RelinquishMagickMemory(header);
- if (number_images > 65535)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- if (AcquireMagickResource(ListLengthResource,number_images) == MagickFalse)
- ThrowReaderException(ResourceLimitError,"ListLengthExceedsLimit");
+ if ((overview != 0) &&
+ (AcquireMagickResource(ListLengthResource,number_images) == MagickFalse))
+ ThrowPCDException(ResourceLimitError,"ListLengthExceedsLimit");
/*
Determine resolution by scene specification.
*/
*/
number_pixels=(MagickSizeType) image->columns*image->rows;
if (number_pixels != (size_t) number_pixels)
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ 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(*luma));
if ((chroma1 == (unsigned char *) NULL) ||
(chroma2 == (unsigned char *) NULL) || (luma == (unsigned char *) NULL))
- {
- if (chroma1 != (unsigned char *) NULL)
- chroma1=(unsigned char *) RelinquishMagickMemory(chroma1);
- if (chroma2 != (unsigned char *) NULL)
- chroma2=(unsigned char *) RelinquishMagickMemory(chroma2);
- if (luma != (unsigned char *) NULL)
- luma=(unsigned char *) RelinquishMagickMemory(luma);
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- }
+ ThrowPCDException(ResourceLimitError,"MemoryAllocationFailed");
(void) memset(chroma1,0,(image->columns+1UL)*image->rows*
10*sizeof(*chroma1));
(void) memset(chroma2,0,(image->columns+1UL)*image->rows*
if (scene <= 1)
offset=1;
for (i=0; i < (ssize_t) (offset*0x800); i++)
- (void) ReadBlobByte(image);
+ if (ReadBlobByte(image) == EOF)
+ ThrowPCDException(CorruptImageError,"UnexpectedEndOfFile");
if (overview != 0)
{
- Image
- *overview_image;
-
MagickProgressMonitor
progress_monitor;
c1+=image->columns;
count=ReadBlob(image,width >> 1,c2);
c2+=image->columns;
+ if (EOFBlob(image) != MagickFalse)
+ ThrowPCDException(CorruptImageError,"UnexpectedEndOfFile");
}
Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma1);
Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma2);
chroma1=(unsigned char *) RelinquishMagickMemory(chroma1);
luma=(unsigned char *) RelinquishMagickMemory(luma);
image=GetFirstImageInList(image);
- overview_image=OverviewImage(image_info,image,exception);
- return(overview_image);
+ return(OverviewImage(image_info,image,exception));
}
/*
Read interleaved image.
c1+=image->columns;
count=ReadBlob(image,width >> 1,c2);
c2+=image->columns;
+ if (EOFBlob(image) != MagickFalse)
+ ThrowPCDException(CorruptImageError,"UnexpectedEndOfFile");
}
if (scene >= 4)
{
{
char
*color,
+ background[MagickPathExtent],
id[MagickPathExtent],
*next_token,
token[MagickPathExtent],
units=AcquireString("userSpaceOnUse");
*id='\0';
*token='\0';
+ *background='\0';
value=(const char *) NULL;
if ((LocaleCompare((char *) name,"image") == 0) ||
(LocaleCompare((char *) name,"pattern") == 0) ||
{
if (LocaleCompare(keyword,"clip-path") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"clip-path \"%s\"\n",value);
+ (void) FormatLocaleFile(svg_info->file,"clip-path \"%s\"\n",
+ value);
break;
}
if (LocaleCompare(keyword,"clip-rule") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"clip-rule \"%s\"\n",value);
+ (void) FormatLocaleFile(svg_info->file,"clip-rule \"%s\"\n",
+ value);
break;
}
if (LocaleCompare(keyword,"clipPathUnits") == 0)
{
(void) CloneString(&units,value);
- (void) FormatLocaleFile(svg_info->file,"clip-units \"%s\"\n",value);
+ (void) FormatLocaleFile(svg_info->file,"clip-units \"%s\"\n",
+ value);
break;
}
if (LocaleCompare(keyword,"color") == 0)
}
if (LocaleCompare(keyword,"fill-rule") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"fill-rule \"%s\"\n",value);
+ (void) FormatLocaleFile(svg_info->file,"fill-rule \"%s\"\n",
+ value);
break;
}
if (LocaleCompare(keyword,"fill-opacity") == 0)
}
if (LocaleCompare(keyword,"font-style") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"font-style \"%s\"\n",value);
+ (void) FormatLocaleFile(svg_info->file,"font-style \"%s\"\n",
+ value);
break;
}
if (LocaleCompare(keyword,"font-size") == 0)
{
if (LocaleCompare(value,"currentColor") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"stroke \"%s\"\n",color);
+ (void) FormatLocaleFile(svg_info->file,"stroke \"%s\"\n",
+ color);
break;
}
(void) FormatLocaleFile(svg_info->file,"stroke \"%s\"\n",value);
}
if (LocaleCompare(keyword,"stroke-miterlimit") == 0)
{
- (void) FormatLocaleFile(svg_info->file,"stroke-miterlimit \"%s\"\n",
- value);
+ (void) FormatLocaleFile(svg_info->file,
+ "stroke-miterlimit \"%s\"\n",value);
break;
}
if (LocaleCompare(keyword,"stroke-opacity") == 0)
" %s: %s",keyword,value);
switch (*keyword)
{
+ case 'B':
+ case 'b':
+ {
+ if (LocaleCompare((const char *) name,"background") == 0)
+ {
+ if (LocaleCompare((const char *) name,"svg") == 0)
+ (void) CopyMagickString(background,value,
+ MagickPathExtent);
+ break;
+ }
+ break;
+ }
case 'C':
case 'c':
{
(void) FormatLocaleFile(svg_info->file,
"fill '#000000'\n");
else
- (void) FormatLocaleFile(svg_info->file,"fill \"%s\"\n",
- value);
+ (void) FormatLocaleFile(svg_info->file,
+ "fill \"%s\"\n",value);
break;
}
if (LocaleCompare(keyword,"fillcolor") == 0)
0.0;
(void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g %g %g\n",
sx,sy,tx,ty);
+ if (*background != '\0')
+ {
+ (void) FormatLocaleFile(svg_info->file,"push graphic-context\n");
+ (void) FormatLocaleFile(svg_info->file,"fill %s\n",background);
+ (void) FormatLocaleFile(svg_info->file,
+ "rectangle 0,0 %g,%g\n",svg_info->view_box.width,
+ svg_info->view_box.height);
+ (void) FormatLocaleFile(svg_info->file,"pop graphic-context\n");
+ }
}
}
(void) LogMagickEvent(CoderEvent,GetMagickModule()," )");