]> granicus.if.org Git - imagemagick/blobdiff - coders/pgx.c
...
[imagemagick] / coders / pgx.c
index 77749c3cbc4617e0c580276066930154b87340f5..077f55984177eaa158278dfeeab79bea07a93999 100644 (file)
@@ -182,6 +182,8 @@ static Image *ReadPGXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   count=(ssize_t) sscanf(buffer,"PG%[ \t]%2s%[ \t+-]%d%[ \t]%d%[ \t]%d",sans,
     endian,sign,&precision,sans,&width,sans,&height);
+  if (count != 8)
+    ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   image->depth=(size_t) precision;
   if (LocaleCompare(endian,"ML") == 0)
     image->endian=MSBEndian;
@@ -200,7 +202,7 @@ static Image *ReadPGXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Convert PGX image.
   */
-  (void) SetImageColorspace(image,sGRAYColorspace,exception);
+  (void) SetImageColorspace(image,GRAYColorspace,exception);
   quantum_info=AcquireQuantumInfo(image_info,image);
   if (quantum_info == (QuantumInfo *) NULL)
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
@@ -363,8 +365,8 @@ static MagickBooleanType WritePGXImage(const ImageInfo *image_info,Image *image,
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
   if (status == MagickFalse)
     return(status);
-  (void) FormatLocaleString(buffer,MagickPathExtent,"PG ML + %ld %lu %lu\n",
-    image->depth,image->columns,image->rows);
+  (void) FormatLocaleString(buffer,MagickPathExtent,"PG ML + %g %g %g\n",
+    (double) image->depth,(double) image->columns,(double) image->rows);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
   (void) TransformImageColorspace(image,sRGBColorspace,exception);
   quantum_info=AcquireQuantumInfo(image_info,image);