From 67475cb6aa3af3a0c65351562c22f25814a45fcb Mon Sep 17 00:00:00 2001 From: scuri Date: Sun, 23 Aug 2009 23:57:50 +0000 Subject: *** empty log message *** --- src/im_file.cpp | 20 +++++++++++++------- src/im_format_gif.cpp | 6 +++++- src/im_format_tiff.cpp | 6 ++++-- src/im_format_wmv.cpp | 7 ++++++- 4 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/im_file.cpp b/src/im_file.cpp index 5cfe49d..3bfa779 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.4 2009/08/19 18:39:43 scuri Exp $ + * $Id: im_file.cpp,v 1.5 2009/08/23 23:57:51 scuri Exp $ */ #include @@ -45,6 +45,16 @@ void imFileClear(imFile* ifile) ifile->palette[i] = imColorEncode((imbyte)i, (imbyte)i, (imbyte)i); } +void imFileSetBaseAttributes(imFile* ifile) +{ + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; + imAttribTable* atable = (imAttribTable*)ifileformat->attrib_table; + + atable->Set("FileFormat", IM_BYTE, -1, ifileformat->iformat->format); + atable->Set("FileCompression", IM_BYTE, -1, ifileformat->compression); + atable->Set("FileImageCount", IM_INT, 1, &ifileformat->image_count); +} + imFile* imFileOpen(const char* file_name, int *error) { assert(file_name); @@ -56,9 +66,7 @@ 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); + imFileSetBaseAttributes(ifileformat); ifileformat->counter = imCounterBegin(file_name); @@ -76,9 +84,7 @@ 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); + imFileSetBaseAttributes(ifileformat); ifileformat->counter = imCounterBegin(file_name); diff --git a/src/im_format_gif.cpp b/src/im_format_gif.cpp index d616504..caadd0f 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.4 2009/08/19 18:39:43 scuri Exp $ + * $Id: im_format_gif.cpp,v 1.5 2009/08/23 23:57:51 scuri Exp $ */ #include "im_format.h" @@ -1247,7 +1247,11 @@ int imFileFormatGIF::GIFWriteImageInfo() int imFileFormatGIF::ReadImageInfo(int index) { imAttribTable* attrib_table = AttribTable(); + + /* must clear the attribute list, because it can have multiple images and + has many attributes that may exists only for specific images. */ attrib_table->RemoveAll(); + imFileSetBaseAttributes(this); if (gif_data.screen_width) { diff --git a/src/im_format_tiff.cpp b/src/im_format_tiff.cpp index 5b072fc..b5e06c5 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.4 2009/08/22 04:31:04 scuri Exp $ + * $Id: im_format_tiff.cpp,v 1.5 2009/08/23 23:57:51 scuri Exp $ */ #include "im_format.h" @@ -762,8 +762,10 @@ int imFileFormatTIFF::ReadImageInfo(int index) uint16* sub_ifd = (uint16*)attrib_table->Get("SubIFDSelect"); - /* must clear the attribute list, because TIFF can have many different images */ + /* must clear the attribute list, because it can have multiple images and + has many attributes that may exists only for specific images. */ attrib_table->RemoveAll(); + imFileSetBaseAttributes(this); void* data = NULL; if (TIFFGetField(this->tiff, TIFFTAG_DNGVERSION, &data) == 1 && data) diff --git a/src/im_format_wmv.cpp b/src/im_format_wmv.cpp index a4733a5..4f3b31b 100644 --- a/src/im_format_wmv.cpp +++ b/src/im_format_wmv.cpp @@ -2,7 +2,7 @@ * \brief WMV - Windows Media Video Format * * See Copyright Notice in im_lib.h - * $Id: im_format_wmv.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ + * $Id: im_format_wmv.cpp,v 1.3 2009/08/23 23:57:52 scuri Exp $ */ #include "im_format.h" @@ -1175,6 +1175,11 @@ int imFileFormatWMV::ReadImageInfo(int index) imAttribTable* attrib_table = AttribTable(); + /* must clear the attribute list, because it can have multiple images and + has many attributes that may exists only for specific images. */ + attrib_table->RemoveAll(); + imFileSetBaseAttributes(this); + if (MediaType->formattype == WMFORMAT_VideoInfo) { WMVIDEOINFOHEADER* info_header = (WMVIDEOINFOHEADER*)MediaType->pbFormat; -- cgit v1.2.3