diff options
| -rw-r--r-- | html/en/history.html | 3 | ||||
| -rw-r--r-- | include/im.h | 13 | ||||
| -rw-r--r-- | include/im_attrib.h | 1 | ||||
| -rw-r--r-- | src/im_attrib.cpp | 5 | ||||
| -rw-r--r-- | src/im_file.cpp | 8 | ||||
| -rw-r--r-- | src/im_format_bmp.cpp | 4 | ||||
| -rw-r--r-- | src/im_format_gif.cpp | 4 | ||||
| -rw-r--r-- | src/im_format_jpeg.cpp | 10 | ||||
| -rw-r--r-- | src/im_format_pcx.cpp | 4 | ||||
| -rw-r--r-- | src/im_format_png.cpp | 14 | ||||
| -rw-r--r-- | src/im_format_tiff.cpp | 6 | ||||
| -rw-r--r-- | src/old_im.cpp | 6 | 
12 files changed, 48 insertions, 30 deletions
| diff --git a/html/en/history.html b/html/en/history.html index 6944ac9..731a424 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -19,6 +19,9 @@  		<li><span style="color: #0000FF">New:</span> functions <strong>  		im.ConvertDataTypeNew</strong>, <strong>im.ConvertColorSpaceNew</strong>   		and <strong>im.ConvertToBitmapNew</strong> in Lua.</li> +		<li><span style="color: #0000FF">New:</span> file attributes  +		"FileFormat", "FileCompression" and "FileImageCount" when reading from  +		file. Available for all formats.</li>  		<li><span style="color: #008000">Changed:</span> libPNG updated to version   	1.2.37. Removed changes to the library that made it incompatible with other   		libPNG distributions.</li> diff --git a/include/im.h b/include/im.h index a6673cb..a324199 100644 --- a/include/im.h +++ b/include/im.h @@ -114,9 +114,13 @@ void imFileClose(imFile* ifile);  void* imFileHandle(imFile* ifile, int index);    /** Returns file information.  - *  image_count is the number of images in a stack or  - *  the number of frames in a video/animation or the depth of a volume data. \n - *  compression and image_count can be NULL. + * image_count is the number of images in a stack or  + * the number of frames in a video/animation or the depth of a volume data. \n + * compression and image_count can be NULL. \n + * These informations are also available as attributes: + * \verbatim FileFormat (string) \endverbatim + * \verbatim FileCompression (string) \endverbatim + * \verbatim FileImageCount IM_INT (1) \endverbatim   * See also \ref format.   *   * \verbatim ifile:GetInfo() -> format: string, compression: string, image_count: number [in Lua 5] \endverbatim @@ -134,7 +138,8 @@ void imFileSetInfo(imFile* ifile, const char* compression);  /** Changes an extended attribute. \n   * The data will be internally duplicated. \n - * If data is NULL the attribute is removed. + * If data is NULL the attribute is removed.  + * If data_type is BYTE then count can be -1 to indicate a NULL terminated string.   * See also \ref imDataType.   *   * \verbatim ifile:SetAttribute(attrib: string, data_type: number, data: table of numbers or string) [in Lua 5] \endverbatim diff --git a/include/im_attrib.h b/include/im_attrib.h index 3dec798..76302ef 100644 --- a/include/im_attrib.h +++ b/include/im_attrib.h @@ -46,6 +46,7 @@ public:      { imAttribTableCopyFrom(ptable, table.ptable); }    /** Inserts an attribute into the table. \n  +   * If data_type is BYTE then count can be -1 to indicate a NULL terminated string.     * Data is duplicated if not NULL, else data is initialized with zeros.     * See also \ref imDataType. */    void Set(const char* name, int data_type, int count, const void* data) 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 = ¶m_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) | 
