From 532b0c33a749fb69718ba5713e9795ae2167897f Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Sat, 20 Mar 2004 10:41:20 +0000 Subject: [PATCH] Added Thumbnail::dataSize --- src/exif.cpp | 33 +++++++++++++++++++++++++-------- src/exif.hpp | 16 ++++++++++++---- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/exif.cpp b/src/exif.cpp index 0f608b93..9f003e88 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -20,14 +20,14 @@ */ /* File: exif.cpp - Version: $Name: $ $Revision: 1.30 $ + Version: $Name: $ $Revision: 1.31 $ Author(s): Andreas Huggel (ahu) History: 26-Jan-04, ahu: created 11-Feb-04, ahu: isolated as a component */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.30 $ $RCSfile: exif.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.31 $ $RCSfile: exif.cpp,v $") // ***************************************************************************** // included header files @@ -416,18 +416,34 @@ namespace Exif { return size; } - long Thumbnail::size() const + long Thumbnail::dataSize() const { long size = 0; switch (type_) { case jpeg: size = size_; break; - case tiff: + case tiff: size = size_ - ifd_.offset() - ifd_.size() - ifd_.dataSize(); break; - case none: - size = 0; + case none: + size = 0; + break; + } + return size; + } + + long Thumbnail::size() const + { + long size = 0; + switch (type_) { + case jpeg: + // fallthrough + case tiff: + size = size_; + break; + case none: + size = 0; break; } return size; @@ -743,13 +759,14 @@ std::cerr << "->>>>>> writing from metadata <<<<<<-\n"; for (e = ifdEntries.begin(); e != eEnd; ++e) { size += 2 + 12 * e->second + 4; } - size += thumbnail_.size(); + // Add the size of the thumbnail image data (w/o IFD for TIFF thumbs) + size += thumbnail_.dataSize(); // Add 1k to account for the possibility that Thumbnail::update // may add entries to IFD1 size += 1024; } return size; - } + } // ExifData::size void ExifData::add(Entries::const_iterator begin, Entries::const_iterator end, diff --git a/src/exif.hpp b/src/exif.hpp index 2ba8d8ee..e7009339 100644 --- a/src/exif.hpp +++ b/src/exif.hpp @@ -21,7 +21,7 @@ /*! @file exif.hpp @brief Encoding and decoding of %Exif data - @version $Name: $ $Revision: 1.29 $ + @version $Name: $ $Revision: 1.30 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 09-Jan-04, ahu: created @@ -312,10 +312,15 @@ namespace Exif { */ void setOffsets(Ifd& ifd1, ByteOrder byteOrder) const; /*! - @brief Return the size of the thumbnail data (data only, without the - IFD, in case of a TIFF thumbnail. + @brief Return the size of the thumbnail image (the size it + would occupy when extracted from the %Exif data) */ long size() const; + /*! + @brief Return the size of the thumbnail data (data only, without the + IFD, in case of a TIFF thumbnail). + */ + long dataSize() const; //! Return the type of the thumbnail Type type() const { return type_; } //@} @@ -579,7 +584,10 @@ namespace Exif { { return thumbnail_.write(path); } //! Return the type of the thumbnail Thumbnail::Type thumbnailType() const { return thumbnail_.type(); } - //! Return the size of the thumbnail data + /*! + @brief Return the size of the thumbnail image. This is the size it + would occupy when extracted from the %Exif data). + */ long thumbnailSize() const { return thumbnail_.size(); } //@}