]> granicus.if.org Git - imagemagick/blobdiff - coders/cals.c
Fixed dds:cluster-fit option.
[imagemagick] / coders / cals.c
index a4f46f4d93d55e436a12f9929a13223810cbf276..93381a774a51221b05d27f2f2913a201126e1608 100644 (file)
 %                 Read/Write CALS Raster Group 1 Image Format                 %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 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/colorspace.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/geometry.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/option.h"
-#include "magick/quantum-private.h"
-#include "magick/resource_.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/geometry.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/option.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
 \f
+#if defined(MAGICKCORE_TIFF_DELEGATE)
 /*
  Forward declarations.
 */
 static MagickBooleanType
-  WriteCALSImage(const ImageInfo *,Image *);
+  WriteCALSImage(const ImageInfo *,Image *,ExceptionInfo *);
+#endif
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -161,7 +164,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   unsigned long
@@ -183,7 +186,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
       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)
     {
@@ -226,7 +229,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
             if (pel_path == 90)
               orientation=5;
             else
-              if (pel_path == 90)
+              if (pel_path == 180)
                 orientation=3;
               else
                 if (pel_path == 270)
@@ -260,12 +263,12 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
   image=DestroyImage(image);
   read_info=CloneImageInfo(image_info);
   SetImageInfoBlob(read_info,(void *) NULL,0);
-  (void) FormatMagickString(read_info->filename,MaxTextExtent,"group4:%.1024s",
+  (void) FormatLocaleString(read_info->filename,MaxTextExtent,"group4:%s",
     filename);
-  (void) FormatMagickString(message,MaxTextExtent,"%lux%lu",width,height);
-  read_info->size=ConstantString(message);
-  (void) FormatMagickString(message,MaxTextExtent,"%lu",density);
-  read_info->density=ConstantString(message);
+  (void) FormatLocaleString(message,MaxTextExtent,"%lux%lu",width,height);
+  (void) CloneString(&read_info->size,message);
+  (void) FormatLocaleString(message,MaxTextExtent,"%lu",density);
+  (void) CloneString(&read_info->density,message);
   read_info->orientation=(OrientationType) orientation;
   image=ReadImage(read_info,exception);
   if (image != (Image *) NULL)
@@ -301,10 +304,10 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
 %
 %  The format of the RegisterCALSImage method is:
 %
-%      unsigned long RegisterCALSImage(void)
+%      size_t RegisterCALSImage(void)
 %
 */
-ModuleExport unsigned long RegisterCALSImage(void)
+ModuleExport size_t RegisterCALSImage(void)
 {
   MagickInfo
     *entry;
@@ -312,7 +315,7 @@ ModuleExport unsigned long RegisterCALSImage(void)
   static const char
     *CALSDescription=
     {
-      "Continuous Acquisition and Life-cycle Support Type 1 Image"
+      "Continuous Acquisition and Life-cycle Support Type 1"
     },
     *CALSNote=
     {
@@ -369,6 +372,7 @@ ModuleExport void UnregisterCALSImage(void)
   (void) UnregisterMagickInfo("CALS");
 }
 \f
+#if defined(MAGICKCORE_TIFF_DELEGATE)
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -386,7 +390,7 @@ ModuleExport void UnregisterCALSImage(void)
 %  The format of the WriteCALSImage method is:
 %
 %      MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
-%        Image *image)
+%        Image *image,ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
 %
@@ -394,6 +398,8 @@ ModuleExport void UnregisterCALSImage(void)
 %
 %    o image:  The image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 
 static ssize_t WriteCALSRecord(Image *image,const char *data)
@@ -401,16 +407,17 @@ static ssize_t WriteCALSRecord(Image *image,const char *data)
   char
     pad[128];
 
-  ssize_t
-    count;
-
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    count;
+
   i=0;
+  count=0;
   if (data != (const char *) NULL)
     {
       p=data;
@@ -420,14 +427,14 @@ static ssize_t WriteCALSRecord(Image *image,const char *data)
   if (i < 128)
     {
       i=128-i;
-      (void) ResetMagickMemory(pad,' ',(const size_t) i);
+      (void) ResetMagickMemory(pad,' ',(size_t) i);
       count=WriteBlob(image,(size_t) i,(const unsigned char *) pad);
     }
   return(count);
 }
 
 static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
-  Image *image)
+  Image *image,ExceptionInfo *exception)
 {
   char
     header[129];
@@ -441,23 +448,21 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
+  size_t
+    density,
+    length,
+    orient_x,
+    orient_y;
+
   ssize_t
     count;
 
-  size_t
-    length;
-
   unsigned char
     *group4;
 
-  unsigned long
-    density,
-    orient_x,
-    orient_y;
-
   /*
     Open output image file.
   */
@@ -467,13 +472,16 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickSignature);
+  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
   if (status == MagickFalse)
     return(status);
   /*
     Create standard CALS header.
   */
   count=WriteCALSRecord(image,"srcdocid: NONE");
+  (void) count;
   count=WriteCALSRecord(image,"dstdocid: NONE");
   count=WriteCALSRecord(image,"txtfilid: NONE");
   count=WriteCALSRecord(image,"figid: NONE");
@@ -528,11 +536,11 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
       orient_y=270;
     }
   }
-  (void) FormatMagickString(header,MaxTextExtent,"rorient: %03ld,%03ld",
-    orient_x,orient_y);
+  (void) FormatLocaleString(header,MaxTextExtent,"rorient: %03ld,%03ld",
+    (long) orient_x,(long) orient_y);
   count=WriteCALSRecord(image,header);
-  (void) FormatMagickString(header,MaxTextExtent,"rpelcnt: %06lu,%06lu",
-    image->columns,image->rows);
+  (void) FormatLocaleString(header,MaxTextExtent,"rpelcnt: %06lu,%06lu",
+    (unsigned long) image->columns,(unsigned long) image->rows);
   count=WriteCALSRecord(image,header);  
   density=200;
   if (image_info->density != (char *) NULL)
@@ -541,9 +549,10 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
         geometry_info;
 
       (void) ParseGeometry(image_info->density,&geometry_info);
-      density=(unsigned long) (geometry_info.rho+0.5);
+      density=(size_t) floor(geometry_info.rho+0.5);
     }
-  (void) FormatMagickString(header,MaxTextExtent,"rdensty: %04lu",density);
+  (void) FormatLocaleString(header,MaxTextExtent,"rdensty: %04lu",
+    (unsigned long) density);
   count=WriteCALSRecord(image,header);
   count=WriteCALSRecord(image,"notes: NONE");
   (void) ResetMagickMemory(header,' ',128);
@@ -555,14 +564,14 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
   write_info=CloneImageInfo(image_info);
   (void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent);
   (void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent);
-  group4_image=CloneImage(image,0,0,MagickTrue,&image->exception);
+  group4_image=CloneImage(image,0,0,MagickTrue,exception);
   if (group4_image == (Image *) NULL)
     {
       (void) CloseBlob(image);
       return(MagickFalse);
     }
   group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
-    &image->exception);
+    exception);
   group4_image=DestroyImage(group4_image);
   if (group4 == (unsigned char *) NULL)
     {
@@ -576,3 +585,4 @@ static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
   (void) CloseBlob(image);
   return(status);
 }
+#endif