]> granicus.if.org Git - imagemagick/blobdiff - coders/sct.c
(no commit message)
[imagemagick] / coders / sct.c
index ff8d500c504bdded1c35d2ad59f631aed282a77f..69370772e190d3a369301fe2c8607afd0a6d21e6 100644 (file)
 %                    Read Scitex HandShake Image Format                       %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2015 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/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/module.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/string-private.h"
+#include "MagickCore/studio.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/module.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/string-private.h"
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -126,36 +127,31 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   Image
     *image;
 
-  long
-    y;
-
   MagickBooleanType
     status;
 
-  MagickRealType
+  double
     height,
     width;
 
   Quantum
     pixel;
 
-  register IndexPacket
-    *indexes;
-
-  register long
+  register ssize_t
     i,
     x;
 
-  register PixelPacket
+  register Quantum
     *q;
 
   ssize_t
-    count;
+    count,
+    y;
 
   unsigned char
     buffer[768];
 
-  unsigned long
+  size_t
     separations,
     separations_mask,
     units;
@@ -170,7 +166,7 @@ static Image *ReadSCTImage(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)
     {
@@ -181,6 +177,7 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Read control block.
   */
   count=ReadBlob(image,80,buffer);
+  (void) count;
   count=ReadBlob(image,2,(unsigned char *) magick);
   if ((LocaleNCompare((char *) magick,"CT",2) != 0) &&
       (LocaleNCompare((char *) magick,"LW",2) != 0) &&
@@ -205,9 +202,9 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   separations_mask=ReadBlobMSBShort(image);
   count=ReadBlob(image,14,buffer);
   buffer[14]='\0';
-  height=StringToDouble((char *) buffer);
+  height=StringToDouble((char *) buffer,(char **) NULL);
   count=ReadBlob(image,14,buffer);
-  width=StringToDouble((char *) buffer);
+  width=StringToDouble((char *) buffer,(char **) NULL);
   count=ReadBlob(image,12,buffer);
   buffer[12]='\0';
   image->rows=StringToUnsignedLong((char *) buffer);
@@ -216,26 +213,28 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   count=ReadBlob(image,200,buffer);
   count=ReadBlob(image,768,buffer);
   if (separations_mask == 0x0f)
-    image->colorspace=CMYKColorspace;
-  image->x_resolution=1.0*image->columns/width;
-  image->y_resolution=1.0*image->rows/height;
+    SetImageColorspace(image,CMYKColorspace,exception);
+  image->resolution.x=1.0*image->columns/width;
+  image->resolution.y=1.0*image->rows/height;
   if (image_info->ping != MagickFalse)
     {
       (void) CloseBlob(image);
       return(GetFirstImageInList(image));
     }
+  status=SetImageExtent(image,image->columns,image->rows,exception);
+  if (status == MagickFalse)
+    return(DestroyImageList(image));
   /*
     Convert SCT raster image to pixel packets.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    for (i=0; i < (long) separations; i++)
+    for (i=0; i < (ssize_t) separations; i++)
     {
       q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
-      if (q == (PixelPacket *) NULL)
+      if (q == (Quantum *) NULL)
         break;
-      indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         pixel=(Quantum) ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
         if (image->colorspace == CMYKColorspace)
@@ -244,36 +243,37 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
         {
           case 0:
           {
-            q->red=pixel;
-            q->green=pixel;
-            q->blue=pixel;
+            SetPixelRed(image,pixel,q);
+            SetPixelGreen(image,pixel,q);
+            SetPixelBlue(image,pixel,q);
             break;
           }
           case 1:
           {
-            q->green=pixel;
+            SetPixelGreen(image,pixel,q);
             break;
           }
           case 2:
           {
-            q->blue=pixel; break;
+            SetPixelBlue(image,pixel,q);
             break;
           }
           case 3: 
           {
             if (image->colorspace == CMYKColorspace)
-              indexes[x]=(IndexPacket) pixel;
+              SetPixelBlack(image,pixel,q);
             break;
           }
         }
-        q++;
+        q+=GetPixelChannels(image);
       }
       if (SyncAuthenticPixels(image,exception) == MagickFalse)
         break;
       if ((image->columns % 2) != 0)
         (void) ReadBlobByte(image);  /* pad */
     }
-    status=SetImageProgress(image,LoadImageTag,y,image->rows);
+    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+      image->rows);
     if (status == MagickFalse)
       break;
   }
@@ -304,20 +304,18 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 %
 %  The format of the RegisterSCTImage method is:
 %
-%      unsigned long RegisterSCTImage(void)
+%      size_t RegisterSCTImage(void)
 %
 */
-ModuleExport unsigned long RegisterSCTImage(void)
+ModuleExport size_t RegisterSCTImage(void)
 {
   MagickInfo
     *entry;
 
-  entry=SetMagickInfo("SCT");
+  entry=AcquireMagickInfo("SCT","SCT","Scitex HandShake");
   entry->decoder=(DecodeImageHandler *) ReadSCTImage;
   entry->magick=(IsImageFormatHandler *) IsSCT;
-  entry->adjoin=MagickFalse;
-  entry->description=ConstantString("Scitex HandShake");
-  entry->module=ConstantString("SCT");
+  entry->flags^=CoderAdjoinFlag;
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }