From 43522c5f2a12dc0cf3cda733e4fb5c04cd62a154 Mon Sep 17 00:00:00 2001
From: scuri <scuri>
Date: Wed, 19 Aug 2009 18:39:31 +0000
Subject: *** empty log message ***

---
 src/im_attrib.cpp      |  5 ++++-
 src/im_file.cpp        |  8 +++++++-
 src/im_format_bmp.cpp  |  4 ++--
 src/im_format_gif.cpp  |  4 ++--
 src/im_format_jpeg.cpp | 10 +++++-----
 src/im_format_pcx.cpp  |  4 ++--
 src/im_format_png.cpp  | 14 +++++++-------
 src/im_format_tiff.cpp |  6 +++---
 src/old_im.cpp         |  6 +++---
 9 files changed, 35 insertions(+), 26 deletions(-)

(limited to 'src')

diff --git a/src/im_attrib.cpp b/src/im_attrib.cpp
index a1b95b7..90c007e 100644
--- a/src/im_attrib.cpp
+++ b/src/im_attrib.cpp
@@ -2,7 +2,7 @@
  * \brief Attributes Table
  *
  * See Copyright Notice in im_lib.h
- * $Id: im_attrib.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $
+ * $Id: im_attrib.cpp,v 1.2 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include <stdlib.h>
@@ -152,6 +152,9 @@ void imAttribTableSet(imAttribTablePrivate* ptable, const char* name, int data_t
   int index = iHashIndex(name, ptable->hash_size);
   imAttribNode* first_node = ptable->hash_table[index];
 
+  if (data_type == 0 && count == -1)  /* BYTE */
+    count = strlen((char*)data)+1;
+
   // The name already exists ?
   imAttribNode* cur_node = first_node;
   imAttribNode* prev_node = NULL;
diff --git a/src/im_file.cpp b/src/im_file.cpp
index 81e0e1b..5cfe49d 100644
--- a/src/im_file.cpp
+++ b/src/im_file.cpp
@@ -2,7 +2,7 @@
  * \brief File Access
  *
  * See Copyright Notice in im_lib.h
- * $Id: im_file.cpp,v 1.3 2009/08/13 22:34:25 scuri Exp $
+ * $Id: im_file.cpp,v 1.4 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include <stdlib.h>
@@ -56,6 +56,9 @@ imFile* imFileOpen(const char* file_name, int *error)
   imFileClear(ifileformat);
 
   ifileformat->attrib_table = new imAttribTable(599);
+  imFileSetAttribute(ifileformat, "FileFormat", IM_BYTE, -1, ifileformat->iformat->format);
+  imFileSetAttribute(ifileformat, "FileCompression", IM_BYTE, -1, ifileformat->compression);
+  imFileSetAttribute(ifileformat, "FileImageCount", IM_INT, 1, &ifileformat->image_count);
 
   ifileformat->counter = imCounterBegin(file_name);
 
@@ -73,6 +76,9 @@ imFile* imFileOpenAs(const char* file_name, const char* format, int *error)
   imFileClear(ifileformat);
 
   ifileformat->attrib_table = new imAttribTable(599);
+  imFileSetAttribute(ifileformat, "FileFormat", IM_BYTE, -1, ifileformat->iformat->format);
+  imFileSetAttribute(ifileformat, "FileCompression", IM_BYTE, -1, ifileformat->compression);
+  imFileSetAttribute(ifileformat, "FileImageCount", IM_INT, 1, &ifileformat->image_count);
 
   ifileformat->counter = imCounterBegin(file_name);
 
diff --git a/src/im_format_bmp.cpp b/src/im_format_bmp.cpp
index 5ec4938..b9b52dd 100644
--- a/src/im_format_bmp.cpp
+++ b/src/im_format_bmp.cpp
@@ -2,7 +2,7 @@
  * \brief BMP - Windows Device Independent Bitmap
  *
  * See Copyright Notice in im_lib.h
- * $Id: im_format_bmp.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $
+ * $Id: im_format_bmp.cpp,v 1.3 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -541,7 +541,7 @@ int imFileFormatBMP::ReadImageInfo(int index)
     imAttribTable* attrib_table = AttribTable();
     attrib_table->Set("XResolution", IM_FLOAT, 1, &xres);
     attrib_table->Set("YResolution", IM_FLOAT, 1, &yres);
-    attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPC");
+    attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPC");
   }
 
   if (this->bpp <= 8)
diff --git a/src/im_format_gif.cpp b/src/im_format_gif.cpp
index 8489331..d616504 100644
--- a/src/im_format_gif.cpp
+++ b/src/im_format_gif.cpp
@@ -2,7 +2,7 @@
  * \brief GIF - Graphics Interchange Format
  *
  * See Copyright Notice in im_lib.h
- * $Id: im_format_gif.cpp,v 1.3 2009/08/13 22:34:25 scuri Exp $
+ * $Id: im_format_gif.cpp,v 1.4 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -651,7 +651,7 @@ static void iGIFReadGraphicsControl(imBinFile* handle, imAttribTable* attrib_tab
       break;
     }
 
-    attrib_table->Set("Disposal", IM_BYTE, 6, disposal);
+    attrib_table->Set("Disposal", IM_BYTE, -1, disposal);
   }
 
   /* delay time */
diff --git a/src/im_format_jpeg.cpp b/src/im_format_jpeg.cpp
index 487db0b..5d451da 100644
--- a/src/im_format_jpeg.cpp
+++ b/src/im_format_jpeg.cpp
@@ -3,7 +3,7 @@
  *
  * See Copyright Notice in im_lib.h
  * See libJPEG Copyright Notice in jpeglib.h
- * $Id: im_format_jpeg.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $
+ * $Id: im_format_jpeg.cpp,v 1.3 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -264,9 +264,9 @@ void imFileFormatJPEG::iReadExifAttrib(unsigned char* data, int data_length, imA
           int res_unit = (int)exif_get_short (entry->data, byte_order);
 
           if (res_unit == 2)
-            attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPI");
+            attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPI");
           else if (res_unit == 3)
-            attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPC");
+            attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPC");
 
           continue;
         }
@@ -604,9 +604,9 @@ int imFileFormatJPEG::ReadImageInfo(int index)
           yres = (float)this->dinfo.Y_density;
 
     if (this->dinfo.density_unit == 1)
-      attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPI");
+      attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPI");
     else
-      attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPC");
+      attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPC");
 
     attrib_table->Set("XResolution", IM_FLOAT, 1, (void*)&xres);
     attrib_table->Set("YResolution", IM_FLOAT, 1, (void*)&yres);
diff --git a/src/im_format_pcx.cpp b/src/im_format_pcx.cpp
index fd206ae..d340927 100644
--- a/src/im_format_pcx.cpp
+++ b/src/im_format_pcx.cpp
@@ -2,7 +2,7 @@
  * \brief PCX - ZSoft Picture
  *
  * See Copyright Notice in im_lib.h
- * $Id: im_format_pcx.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $
+ * $Id: im_format_pcx.cpp,v 1.3 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -300,7 +300,7 @@ int imFileFormatPCX::ReadImageInfo(int index)
   {
     attrib_table->Set("XResolution", IM_FLOAT, 1, &xres);
     attrib_table->Set("YResolution", IM_FLOAT, 1, &yres);
-    attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPI");
+    attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPI");
   }
 
   /* jump 3*16+1 bytes (colormap + reserved) */
diff --git a/src/im_format_png.cpp b/src/im_format_png.cpp
index 5c508e1..e4767cc 100644
--- a/src/im_format_png.cpp
+++ b/src/im_format_png.cpp
@@ -3,7 +3,7 @@
  *
  * See Copyright Notice in im_lib.h
  * See libPNG Copyright Notice in png.h
- * $Id: im_format_png.cpp,v 1.3 2009/08/13 22:34:25 scuri Exp $
+ * $Id: im_format_png.cpp,v 1.4 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -182,7 +182,7 @@ void imFileFormatPNG::iReadAttrib(imAttribTable* attrib_table)
       float yres = yr / 100.0f;
       attrib_table->Set("XResolution", IM_FLOAT, 1, &xres);
       attrib_table->Set("YResolution", IM_FLOAT, 1, &yres);
-      attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPC");
+      attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPC");
     }
   }
 
@@ -257,9 +257,9 @@ void imFileFormatPNG::iReadAttrib(imAttribTable* attrib_table)
     char param_buf[255*100], *param_ptr;
     int p, size, total_size = 0;
 
-    attrib_table->Set("CalibrationName", IM_BYTE, strlen(pcal_purpose)+1, pcal_purpose);
+    attrib_table->Set("CalibrationName", IM_BYTE, -1, pcal_purpose);
     attrib_table->Set("CalibrationLimits", IM_INT, 2, pcal_limits);
-    attrib_table->Set("CalibrationUnits", IM_BYTE, strlen(pcal_units)+1, pcal_units);
+    attrib_table->Set("CalibrationUnits", IM_BYTE, -1, pcal_units);
     attrib_table->Set("CalibrationEquation", IM_BYTE, 1, &pcal_type);
 
     param_ptr = &param_buf[0];
@@ -334,7 +334,7 @@ void imFileFormatPNG::iReadAttrib(imAttribTable* attrib_table)
   if (png_get_tIME(png_ptr, info_ptr, &time))
   {
     char* stime = png_convert_to_rfc1123(png_ptr, time);
-    attrib_table->Set("DateTimeModified", IM_BYTE, strlen(stime)+1, stime);
+    attrib_table->Set("DateTimeModified", IM_BYTE, -1, stime);
   }
 
   png_charp name;
@@ -355,9 +355,9 @@ void imFileFormatPNG::iReadAttrib(imAttribTable* attrib_table)
       attrib_table->Set("XScale", IM_FLOAT, 1, &xscale);
       attrib_table->Set("YScale", IM_FLOAT, 1, &yscale);
       if (scale_unit == PNG_SCALE_METER)
-        attrib_table->Set("ScaleUnit", IM_BYTE, 7, "meters");
+        attrib_table->Set("ScaleUnit", IM_BYTE, -1, "meters");
       else
-        attrib_table->Set("ScaleUnit", IM_BYTE, 8, "radians");
+        attrib_table->Set("ScaleUnit", IM_BYTE, -1, "radians");
     }
   }
 }
diff --git a/src/im_format_tiff.cpp b/src/im_format_tiff.cpp
index 1c55a55..66fbe57 100644
--- a/src/im_format_tiff.cpp
+++ b/src/im_format_tiff.cpp
@@ -3,7 +3,7 @@
  *
  * See Copyright Notice in im_lib.h
  * See libTIFF Copyright Notice in tiff.h
- * $Id: im_format_tiff.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $
+ * $Id: im_format_tiff.cpp,v 1.3 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include "im_format.h"
@@ -479,9 +479,9 @@ static void iTIFFReadAttributes(TIFF* tiff, imAttribTable* attrib_table)
     if (xres != 0 && yres != 0)
     {
       if (ResolutionUnit == RESUNIT_INCH)
-        attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPI");
+        attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPI");
       else
-        attrib_table->Set("ResolutionUnit", IM_BYTE, 4, "DPC");
+        attrib_table->Set("ResolutionUnit", IM_BYTE, -1, "DPC");
 
       attrib_table->Set("XResolution", IM_FLOAT, 1, (void*)&xres);
       attrib_table->Set("YResolution", IM_FLOAT, 1, (void*)&yres);
diff --git a/src/old_im.cpp b/src/old_im.cpp
index 43a8afb..44a0e1c 100644
--- a/src/old_im.cpp
+++ b/src/old_im.cpp
@@ -2,7 +2,7 @@
  * \brief Old API
  *
  * See Copyright Notice in im_lib.h
- * $Id: old_im.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $
+ * $Id: old_im.cpp,v 1.2 2009/08/19 18:39:43 scuri Exp $
  */
 
 #include <stdlib.h>
@@ -339,7 +339,7 @@ int imSaveRGB(int width, int height, int format, unsigned char *red, unsigned ch
   {
     char img_desc[50];
     iOldTiffImageDescCB(filename, img_desc);
-    imFileSetAttribute(ifile, "Description", IM_BYTE, strlen(img_desc)+1, (void*)img_desc);
+    imFileSetAttribute(ifile, "Description", IM_BYTE, -1, (void*)img_desc);
   }
 
   if (iOldGifTranspIndexCB)
@@ -414,7 +414,7 @@ int imSaveMap(int width, int height, int format, unsigned char *map, int palette
   {
     char img_desc[50];
     iOldTiffImageDescCB(filename, img_desc);
-    imFileSetAttribute(ifile, "Description", IM_BYTE, strlen(img_desc)+1, (void*)img_desc);
+    imFileSetAttribute(ifile, "Description", IM_BYTE, -1, (void*)img_desc);
   }
 
   if (iOldGifTranspIndexCB)
-- 
cgit v1.2.3