]> granicus.if.org Git - imagemagick/blobdiff - coders/cmyk.c
(no commit message)
[imagemagick] / coders / cmyk.c
index 14bb7e1219bfb4c011a677fbe0888f33fc5cf0d4..7e7e45eefe6f67ee9f5aa573abab29604a246619 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 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  %
@@ -102,9 +102,6 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
     *canvas_image,
     *image;
 
-  ssize_t
-    y;
-
   MagickBooleanType
     status;
 
@@ -121,7 +118,8 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
     i;
 
   ssize_t
-    count;
+    count,
+    y;
 
   size_t
     length;
@@ -151,13 +149,9 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Create virtual canvas to support cropping (i.e. image.cmyk[100x100+10+20]).
@@ -226,12 +220,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register IndexPacket
             *restrict indexes;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -315,12 +309,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register IndexPacket
             *restrict indexes;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -415,12 +409,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -467,12 +461,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -519,12 +513,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -577,12 +571,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register IndexPacket
             *restrict indexes;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -633,12 +627,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
               register const PixelPacket
                 *restrict p;
 
-              register ssize_t
-                x;
-
               register PixelPacket
                 *restrict q;
 
+              register ssize_t
+                x;
+
               if (count != (ssize_t) length)
                 {
                   ThrowFileException(exception,CorruptImageError,
@@ -703,13 +697,9 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
             image=DestroyImageList(image);
             return((Image *) NULL);
           }
-        for (i=0; i < image->offset; i++)
-          if (ReadBlobByte(image) == EOF)
-            {
-              ThrowFileException(exception,CorruptImageError,
-                "UnexpectedEndOfFile",image->filename);
-              break;
-            }
+        if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+          ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+            image->filename);
         length=GetQuantumExtent(canvas_image,quantum_info,CyanQuantum);
         for (i=0; i < (ssize_t) scene; i++)
           for (y=0; y < (ssize_t) image->extract_info.height; y++)
@@ -725,12 +715,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -796,12 +786,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -867,12 +857,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register const PixelPacket
             *restrict p;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -944,12 +934,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           register IndexPacket
             *restrict indexes;
 
-          register ssize_t
-            x;
-
           register PixelPacket
             *restrict q;
 
+          register ssize_t
+            x;
+
           if (count != (ssize_t) length)
             {
               ThrowFileException(exception,CorruptImageError,
@@ -1019,12 +1009,12 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
               register const PixelPacket
                 *restrict p;
 
-              register ssize_t
-                x;
-
               register PixelPacket
                 *restrict q;
 
+              register ssize_t
+                x;
+
               if (count != (ssize_t) length)
                 {
                   ThrowFileException(exception,CorruptImageError,
@@ -1212,9 +1202,6 @@ ModuleExport void UnregisterCMYKImage(void)
 static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
   Image *image)
 {
-  ssize_t
-    y;
-
   MagickBooleanType
     status;
 
@@ -1228,7 +1215,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
     quantum_type;
 
   ssize_t
-    count;
+    count,
+    y;
 
   size_t
     length;
@@ -1291,8 +1279,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            quantum_type,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,quantum_type,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1319,23 +1307,23 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            CyanQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,CyanQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            MagentaQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,MagentaQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            YellowQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,YellowQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            BlackQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,BlackQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1370,8 +1358,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            CyanQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,CyanQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1390,8 +1378,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            MagentaQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,MagentaQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1410,8 +1398,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            YellowQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,YellowQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1430,8 +1418,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            BlackQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,BlackQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1449,8 +1437,7 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
               register const PixelPacket
                 *restrict p;
 
-              p=GetVirtualPixels(image,0,y,image->columns,1,
-                &image->exception);
+              p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               length=ExportQuantumPixels(image,(const CacheView *) NULL,
@@ -1495,8 +1482,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            CyanQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,CyanQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1521,8 +1508,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            MagentaQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,MagentaQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1547,8 +1534,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            YellowQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,YellowQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;
@@ -1573,8 +1560,8 @@ static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
-            BlackQuantum,pixels,&image->exception);
+          length=ExportQuantumPixels(image,(const CacheView *) NULL,
+            quantum_info,BlackQuantum,pixels,&image->exception);
           count=WriteBlob(image,length,pixels);
           if (count != (ssize_t) length)
             break;