]> granicus.if.org Git - imagemagick/blobdiff - coders/cin.c
(no commit message)
[imagemagick] / coders / cin.c
index 0ec21d4f30d8c380f976b108c97b153bf19e7114..58f258d10ca58ad6f4c9761a6027b483e113af84 100644 (file)
@@ -20,7 +20,7 @@
 %                               October 2003                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 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  %
@@ -425,7 +425,7 @@ static Image *ReadCINImage(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)
     {
@@ -455,16 +455,19 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
   offset+=4;
   offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *)
     cin.file.version);
-  (void) SetImageProperty(image,"dpx:file.version",cin.file.version);
+  (void) SetImageProperty(image,"dpx:file.version",cin.file.version,exception);
   offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *)
     cin.file.filename);
-  (void) SetImageProperty(image,"dpx:file.filename",cin.file.filename);
+  (void) SetImageProperty(image,"dpx:file.filename",cin.file.filename,
+    exception);
   offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *)
     cin.file.create_date);
-  (void) SetImageProperty(image,"dpx:file.create_date",cin.file.create_date);
+  (void) SetImageProperty(image,"dpx:file.create_date",cin.file.create_date,
+    exception);
   offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *)
     cin.file.create_time);
-  (void) SetImageProperty(image,"dpx:file.create_time",cin.file.create_time);
+  (void) SetImageProperty(image,"dpx:file.create_time",cin.file.create_time,
+    exception);
   offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *)
     cin.file.reserve);
   /*
@@ -548,7 +551,7 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1];
   offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *)
     cin.image.label);
-  (void) SetImageProperty(image,"dpx:image.label",cin.image.label);
+  (void) SetImageProperty(image,"dpx:image.label",cin.image.label,exception);
   offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *)
     cin.image.reserve);
   /*
@@ -584,26 +587,27 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
   offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *)
     cin.origination.filename);
   (void) SetImageProperty(image,"dpx:origination.filename",
-    cin.origination.filename);
+    cin.origination.filename,exception);
   offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *)
     cin.origination.create_date);
   (void) SetImageProperty(image,"dpx:origination.create_date",
-    cin.origination.create_date);
+    cin.origination.create_date,exception);
   offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *)
     cin.origination.create_time);
   (void) SetImageProperty(image,"dpx:origination.create_time",
-    cin.origination.create_time);
+    cin.origination.create_time,exception);
   offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *)
     cin.origination.device);
   (void) SetImageProperty(image,"dpx:origination.device",
-    cin.origination.device);
+    cin.origination.device,exception);
   offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *)
     cin.origination.model);
-  (void) SetImageProperty(image,"dpx:origination.model",cin.origination.model);
+  (void) SetImageProperty(image,"dpx:origination.model",cin.origination.model,
+    exception);
   offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *)
     cin.origination.serial);
   (void) SetImageProperty(image,"dpx:origination.serial",
-    cin.origination.serial);
+    cin.origination.serial,exception);
   cin.origination.x_pitch=ReadBlobFloat(image);
   offset+=4;
   cin.origination.y_pitch=ReadBlobFloat(image);
@@ -649,7 +653,8 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
       offset+=4;
       offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *)
         cin.film.format);
-      (void) SetImageProperty(image,"dpx:film.format",cin.film.format);
+      (void) SetImageProperty(image,"dpx:film.format",cin.film.format,
+        exception);
       cin.film.frame_position=ReadBlobLong(image);
       offset+=4;
       if (cin.film.frame_position != ~0UL)
@@ -662,10 +667,12 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
           cin.film.frame_rate);
       offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *)
         cin.film.frame_id);
-      (void) SetImageProperty(image,"dpx:film.frame_id",cin.film.frame_id);
+      (void) SetImageProperty(image,"dpx:film.frame_id",cin.film.frame_id,
+        exception);
       offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *)
         cin.film.slate_info);
-      (void) SetImageProperty(image,"dpx:film.slate_info",cin.film.slate_info);
+      (void) SetImageProperty(image,"dpx:film.slate_info",cin.film.slate_info,
+        exception);
       offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *)
         cin.film.reserve);
     }
@@ -682,7 +689,7 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
       offset+=ReadBlob(image,GetStringInfoLength(profile),
         GetStringInfoDatum(profile));
-      (void) SetImageProfile(image,"dpx:user.data",profile);
+      (void) SetImageProfile(image,"dpx:user.data",profile,exception);
       profile=DestroyStringInfo(profile);
     }
   for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++)
@@ -737,7 +744,7 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (EOFBlob(image) != MagickFalse)
     ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
       image->filename);
-  image->colorspace=LogColorspace;
+  SetImageColorspace(image,LogColorspace,exception);
   (void) CloseBlob(image);
   return(GetFirstImageInList(image));
 }
@@ -833,7 +840,7 @@ ModuleExport void UnregisterCINImage(void)
 */
 
 static inline const char *GetCINProperty(const ImageInfo *image_info,
-  const Image *image,const char *property)
+  const Image *image,const char *property,ExceptionInfo *exception)
 {
   const char
     *value;
@@ -841,7 +848,7 @@ static inline const char *GetCINProperty(const ImageInfo *image_info,
   value=GetImageOption(image_info,property);
   if (value != (const char *) NULL)
     return(value);
-  return(GetImageProperty(image,property));
+  return(GetImageProperty(image,property,exception));
 }
 
 static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
@@ -905,7 +912,7 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   if (status == MagickFalse)
     return(status);
   if (image->colorspace != LogColorspace)
-    (void) TransformImageColorspace(image,LogColorspace);
+    (void) TransformImageColorspace(image,LogColorspace,exception);
   /*
     Write image information.
   */
@@ -932,7 +939,7 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   (void) CopyMagickString(cin.file.version,"V4.5",sizeof(cin.file.version));
   offset+=WriteBlob(image,sizeof(cin.file.version),(unsigned char *)
     cin.file.version);
-  value=GetCINProperty(image_info,image,"dpx:file.filename");
+  value=GetCINProperty(image_info,image,"dpx:file.filename",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.file.filename,value,sizeof(cin.file.filename));
   else
@@ -995,7 +1002,7 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   offset+=WriteBlobFloat(image,image->chromaticity.green_primary.y);
   offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.x);
   offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.y);
-  value=GetCINProperty(image_info,image,"dpx:image.label");
+  value=GetCINProperty(image_info,image,"dpx:image.label",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.image.label,value,sizeof(cin.image.label));
   offset+=WriteBlob(image,sizeof(cin.image.label),(unsigned char *)
@@ -1023,16 +1030,16 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
     Write origination information.
   */
   cin.origination.x_offset=0UL;
-  value=GetCINProperty(image_info,image,"dpx:origination.x_offset");
+  value=GetCINProperty(image_info,image,"dpx:origination.x_offset",exception);
   if (value != (const char *) NULL)
     cin.origination.x_offset=(ssize_t) StringToLong(value);
   offset+=WriteBlobLong(image,(unsigned int) cin.origination.x_offset);
   cin.origination.y_offset=0UL;
-  value=GetCINProperty(image_info,image,"dpx:origination.y_offset");
+  value=GetCINProperty(image_info,image,"dpx:origination.y_offset",exception);
   if (value != (const char *) NULL)
     cin.origination.y_offset=(ssize_t) StringToLong(value);
   offset+=WriteBlobLong(image,(unsigned int) cin.origination.y_offset);
-  value=GetCINProperty(image_info,image,"dpx:origination.filename");
+  value=GetCINProperty(image_info,image,"dpx:origination.filename",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.origination.filename,value,
       sizeof(cin.origination.filename));
@@ -1050,33 +1057,33 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
     sizeof(cin.origination.create_time),"%H:%M:%S%Z",&local_time);
   offset+=WriteBlob(image,sizeof(cin.origination.create_time),(unsigned char *)
     cin.origination.create_time);
-  value=GetCINProperty(image_info,image,"dpx:origination.device");
+  value=GetCINProperty(image_info,image,"dpx:origination.device",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.origination.device,value,
       sizeof(cin.origination.device));
   offset+=WriteBlob(image,sizeof(cin.origination.device),(unsigned char *)
     cin.origination.device);
-  value=GetCINProperty(image_info,image,"dpx:origination.model");
+  value=GetCINProperty(image_info,image,"dpx:origination.model",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.origination.model,value,
       sizeof(cin.origination.model));
   offset+=WriteBlob(image,sizeof(cin.origination.model),(unsigned char *)
     cin.origination.model);
-  value=GetCINProperty(image_info,image,"dpx:origination.serial");
+  value=GetCINProperty(image_info,image,"dpx:origination.serial",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.origination.serial,value,
       sizeof(cin.origination.serial));
   offset+=WriteBlob(image,sizeof(cin.origination.serial),(unsigned char *)
     cin.origination.serial);
   cin.origination.x_pitch=0.0f;
-  value=GetCINProperty(image_info,image,"dpx:origination.x_pitch");
+  value=GetCINProperty(image_info,image,"dpx:origination.x_pitch",exception);
   if (value != (const char *) NULL)
-    cin.origination.x_pitch=InterpretLocaleValue(value,(char **) NULL);
+    cin.origination.x_pitch=StringToDouble(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.origination.x_pitch);
   cin.origination.y_pitch=0.0f;
-  value=GetCINProperty(image_info,image,"dpx:origination.y_pitch");
+  value=GetCINProperty(image_info,image,"dpx:origination.y_pitch",exception);
   if (value != (const char *) NULL)
-    cin.origination.y_pitch=InterpretLocaleValue(value,(char **) NULL);
+    cin.origination.y_pitch=StringToDouble(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.origination.y_pitch);
   cin.origination.gamma=image->gamma;
   offset+=WriteBlobFloat(image,cin.origination.gamma);
@@ -1086,52 +1093,52 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
     Image film information.
   */
   cin.film.id=0;
-  value=GetCINProperty(image_info,image,"dpx:film.id");
+  value=GetCINProperty(image_info,image,"dpx:film.id",exception);
   if (value != (const char *) NULL)
     cin.film.id=(char) StringToLong(value);
   offset+=WriteBlobByte(image,(unsigned char) cin.film.id);
   cin.film.type=0;
-  value=GetCINProperty(image_info,image,"dpx:film.type");
+  value=GetCINProperty(image_info,image,"dpx:film.type",exception);
   if (value != (const char *) NULL)
     cin.film.type=(char) StringToLong(value);
   offset+=WriteBlobByte(image,(unsigned char) cin.film.type);
   cin.film.offset=0;
-  value=GetCINProperty(image_info,image,"dpx:film.offset");
+  value=GetCINProperty(image_info,image,"dpx:film.offset",exception);
   if (value != (const char *) NULL)
     cin.film.offset=(char) StringToLong(value);
   offset+=WriteBlobByte(image,(unsigned char) cin.film.offset);
   offset+=WriteBlobByte(image,(unsigned char) cin.film.reserve1);
   cin.film.prefix=0UL;
-  value=GetCINProperty(image_info,image,"dpx:film.prefix");
+  value=GetCINProperty(image_info,image,"dpx:film.prefix",exception);
   if (value != (const char *) NULL)
     cin.film.prefix=StringToUnsignedLong(value);
   offset+=WriteBlobLong(image,(unsigned int) cin.film.prefix);
   cin.film.count=0UL;
-  value=GetCINProperty(image_info,image,"dpx:film.count");
+  value=GetCINProperty(image_info,image,"dpx:film.count",exception);
   if (value != (const char *) NULL)
     cin.film.count=StringToUnsignedLong(value);
   offset+=WriteBlobLong(image,(unsigned int) cin.film.count);
-  value=GetCINProperty(image_info,image,"dpx:film.format");
+  value=GetCINProperty(image_info,image,"dpx:film.format",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.film.format,value,sizeof(cin.film.format));
   offset+=WriteBlob(image,sizeof(cin.film.format),(unsigned char *)
     cin.film.format);
   cin.film.frame_position=0UL;
-  value=GetCINProperty(image_info,image,"dpx:film.frame_position");
+  value=GetCINProperty(image_info,image,"dpx:film.frame_position",exception);
   if (value != (const char *) NULL)
     cin.film.frame_position=StringToUnsignedLong(value);
   offset+=WriteBlobLong(image,(unsigned int) cin.film.frame_position);
   cin.film.frame_rate=0.0f;
-  value=GetCINProperty(image_info,image,"dpx:film.frame_rate");
+  value=GetCINProperty(image_info,image,"dpx:film.frame_rate",exception);
   if (value != (const char *) NULL)
-    cin.film.frame_rate=InterpretLocaleValue(value,(char **) NULL);
+    cin.film.frame_rate=StringToDouble(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.film.frame_rate);
-  value=GetCINProperty(image_info,image,"dpx:film.frame_id");
+  value=GetCINProperty(image_info,image,"dpx:film.frame_id",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.film.frame_id,value,sizeof(cin.film.frame_id));
   offset+=WriteBlob(image,sizeof(cin.film.frame_id),(unsigned char *)
     cin.film.frame_id);
-  value=GetCINProperty(image_info,image,"dpx:film.slate_info");
+  value=GetCINProperty(image_info,image,"dpx:film.slate_info",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.film.slate_info,value,
       sizeof(cin.film.slate_info));
@@ -1158,7 +1165,7 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   if (0)
     {
       quantum_type=GrayQuantum;
-      length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);
+      length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue);
     }
   for (y=0; y < (ssize_t) image->rows; y++)
   {