]> granicus.if.org Git - imagemagick/blobdiff - coders/rla.c
Accommodate background color index in PLTE chunk
[imagemagick] / coders / rla.c
index e2864ec44be8f05ad7351887ffa072dbd2dfc73f..843fd6fb273ddb449916598210fc5fe505daf81a 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 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  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/property.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/property.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -162,12 +163,6 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     length,
     runlength;
 
-  ssize_t
-    y;
-
-  ssize_t
-    *scanlines;
-
   MagickBooleanType
     status;
 
@@ -178,11 +173,13 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     i,
     x;
 
-  register PixelPacket
+  register Quantum
     *q;
 
   ssize_t
-    count;
+    count,
+    *scanlines,
+    y;
 
   RLAInfo
     rla_info;
@@ -200,7 +197,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     {
@@ -267,7 +264,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (scanlines == (ssize_t *) NULL)
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   if (*rla_info.description != '\0')
-    (void) SetImageProperty(image,"comment",rla_info.description);
+    (void) SetImageProperty(image,"comment",rla_info.description,exception);
   /*
     Read offsets to each scanline data.
   */
@@ -300,7 +297,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               q=GetAuthenticPixels(image,(ssize_t) (x % image->columns),
                 (ssize_t) (y % image->rows),1,1,exception);
-              if (q == (PixelPacket *) NULL)
+              if (q == (Quantum *) NULL)
                 break;
               byte=(unsigned char) ReadBlobByte(image);
               length--;
@@ -308,23 +305,23 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
               {
                 case 0:
                 {
-                  q->red=ScaleCharToQuantum(byte);
+                  SetPixelRed(image,ScaleCharToQuantum(byte),q);
                   break;
                 }
                 case 1:
                 {
-                  q->green=ScaleCharToQuantum(byte);
+                  SetPixelGreen(image,ScaleCharToQuantum(byte),q);
                   break;
                 }
                 case 2:
                 {
-                  q->blue=ScaleCharToQuantum(byte);
+                  SetPixelBlue(image,ScaleCharToQuantum(byte),q);
                   break;
                 }
                 case 3:
                 default:
                 {
-                  q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(byte));
+                  SetPixelAlpha(image,ScaleCharToQuantum(byte),q);
                   break;
                 }
               }
@@ -342,29 +339,29 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
         {
           q=GetAuthenticPixels(image,(ssize_t) (x % image->columns),
             (ssize_t) (y % image->rows),1,1,exception);
-          if (q == (PixelPacket *) NULL)
+          if (q == (Quantum *) NULL)
             break;
           switch (channel)
           {
             case 0:
             {
-              q->red=ScaleCharToQuantum(byte);
+              SetPixelRed(image,ScaleCharToQuantum(byte),q);
               break;
             }
             case 1:
             {
-              q->green=ScaleCharToQuantum(byte);
+              SetPixelGreen(image,ScaleCharToQuantum(byte),q);
               break;
             }
             case 2:
             {
-              q->blue=ScaleCharToQuantum(byte);
+              SetPixelBlue(image,ScaleCharToQuantum(byte),q);
               break;
             }
             case 3:
             default:
             {
-              q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(byte));
+              SetPixelAlpha(image,ScaleCharToQuantum(byte),q);
               break;
             }
           }
@@ -377,7 +374,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
       }
     }
     status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
-                image->rows);
+      image->rows);
     if (status == MagickFalse)
       break;
   }
@@ -419,6 +416,7 @@ ModuleExport size_t RegisterRLAImage(void)
   entry=SetMagickInfo("RLA");
   entry->decoder=(DecodeImageHandler *) ReadRLAImage;
   entry->adjoin=MagickFalse;
+  entry->seekable_stream=MagickTrue;
   entry->description=ConstantString("Alias/Wavefront image");
   entry->module=ConstantString("RLA");
   (void) RegisterMagickInfo(entry);