Added Thumbnail::dataSize

v0.27.3
Andreas Huggel 22 years ago
parent fbab78ef9a
commit 532b0c33a7

@ -20,14 +20,14 @@
*/ */
/* /*
File: exif.cpp File: exif.cpp
Version: $Name: $ $Revision: 1.30 $ Version: $Name: $ $Revision: 1.31 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 26-Jan-04, ahu: created History: 26-Jan-04, ahu: created
11-Feb-04, ahu: isolated as a component 11-Feb-04, ahu: isolated as a component
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #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 // included header files
@ -416,18 +416,34 @@ namespace Exif {
return size; return size;
} }
long Thumbnail::size() const long Thumbnail::dataSize() const
{ {
long size = 0; long size = 0;
switch (type_) { switch (type_) {
case jpeg: case jpeg:
size = size_; size = size_;
break; break;
case tiff: case tiff:
size = size_ - ifd_.offset() - ifd_.size() - ifd_.dataSize(); size = size_ - ifd_.offset() - ifd_.size() - ifd_.dataSize();
break; break;
case none: case none:
size = 0; 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; break;
} }
return size; return size;
@ -743,13 +759,14 @@ std::cerr << "->>>>>> writing from metadata <<<<<<-\n";
for (e = ifdEntries.begin(); e != eEnd; ++e) { for (e = ifdEntries.begin(); e != eEnd; ++e) {
size += 2 + 12 * e->second + 4; 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 // Add 1k to account for the possibility that Thumbnail::update
// may add entries to IFD1 // may add entries to IFD1
size += 1024; size += 1024;
} }
return size; return size;
} } // ExifData::size
void ExifData::add(Entries::const_iterator begin, void ExifData::add(Entries::const_iterator begin,
Entries::const_iterator end, Entries::const_iterator end,

@ -21,7 +21,7 @@
/*! /*!
@file exif.hpp @file exif.hpp
@brief Encoding and decoding of %Exif data @brief Encoding and decoding of %Exif data
@version $Name: $ $Revision: 1.29 $ @version $Name: $ $Revision: 1.30 $
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 09-Jan-04, ahu: created @date 09-Jan-04, ahu: created
@ -312,10 +312,15 @@ namespace Exif {
*/ */
void setOffsets(Ifd& ifd1, ByteOrder byteOrder) const; void setOffsets(Ifd& ifd1, ByteOrder byteOrder) const;
/*! /*!
@brief Return the size of the thumbnail data (data only, without the @brief Return the size of the thumbnail image (the size it
IFD, in case of a TIFF thumbnail. would occupy when extracted from the %Exif data)
*/ */
long size() const; 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 //! Return the type of the thumbnail
Type type() const { return type_; } Type type() const { return type_; }
//@} //@}
@ -579,7 +584,10 @@ namespace Exif {
{ return thumbnail_.write(path); } { return thumbnail_.write(path); }
//! Return the type of the thumbnail //! Return the type of the thumbnail
Thumbnail::Type thumbnailType() const { return thumbnail_.type(); } 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(); } long thumbnailSize() const { return thumbnail_.size(); }
//@} //@}

Loading…
Cancel
Save