Fixed blunders related to non-intrusive writing: Ambiguous Ifd constructor, incomplete implementation of updateIfds
This commit is contained in:
parent
97959c9ae3
commit
9cf3e66801
43
src/exif.cpp
43
src/exif.cpp
@ -20,13 +20,13 @@
|
||||
*/
|
||||
/*
|
||||
File: exif.cpp
|
||||
Version: $Name: $ $Revision: 1.17 $
|
||||
Version: $Name: $ $Revision: 1.18 $
|
||||
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
|
||||
History: 26-Jan-04, ahu: created
|
||||
*/
|
||||
// *****************************************************************************
|
||||
#include "rcsid.hpp"
|
||||
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.17 $ $RCSfile: exif.cpp,v $")
|
||||
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.18 $ $RCSfile: exif.cpp,v $")
|
||||
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
@ -541,6 +541,16 @@ namespace Exif {
|
||||
size_ = value.size();
|
||||
type_ = value.typeId();
|
||||
count_ = value.count();
|
||||
} // Entry::setValue
|
||||
|
||||
Ifd::Ifd(IfdId ifdId)
|
||||
: alloc_(true), ifdId_(ifdId), offset_(0), next_(0)
|
||||
{
|
||||
}
|
||||
|
||||
Ifd::Ifd(IfdId ifdId, uint32 offset)
|
||||
: alloc_(true), ifdId_(ifdId), offset_(offset), next_(0)
|
||||
{
|
||||
}
|
||||
|
||||
Ifd::Ifd(IfdId ifdId, uint32 offset, bool alloc)
|
||||
@ -820,7 +830,7 @@ namespace Exif {
|
||||
} // Ifd::print
|
||||
|
||||
Thumbnail::Thumbnail()
|
||||
: type_(none), size_(0), image_(0), ifd_(ifd1, false)
|
||||
: type_(none), size_(0), image_(0), ifd_(ifd1, 0, false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -830,7 +840,7 @@ namespace Exif {
|
||||
}
|
||||
|
||||
Thumbnail::Thumbnail(const Thumbnail& rhs)
|
||||
: type_(rhs.type_), size_(rhs.size_), image_(0), ifd_(ifd1, false)
|
||||
: type_(rhs.type_), size_(rhs.size_), image_(0), ifd_(ifd1, 0, false)
|
||||
{
|
||||
if (rhs.image_ > 0 && rhs.size_ > 0) {
|
||||
image_ = new char[rhs.size_];
|
||||
@ -1126,9 +1136,9 @@ namespace Exif {
|
||||
} // Thumbnail::setTiffImageOffsets
|
||||
|
||||
ExifData::ExifData()
|
||||
: ifd0_(ifd0, false), exifIfd_(exifIfd, false), iopIfd_(iopIfd, false),
|
||||
gpsIfd_(gpsIfd, false), ifd1_(ifd1, false), valid_(false),
|
||||
size_(0), data_(0)
|
||||
: ifd0_(ifd0, 0, false), exifIfd_(exifIfd, 0, false),
|
||||
iopIfd_(iopIfd, 0, false), gpsIfd_(gpsIfd, 0, false),
|
||||
ifd1_(ifd1, 0, false), valid_(false), size_(0), data_(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1407,14 +1417,24 @@ std::cout << "->>>>>> writing from metadata <<<<<<-\n";
|
||||
if (!this->compatible()) return false;
|
||||
|
||||
bool compatible = true;
|
||||
compatible |= updateIfd(ifd0_);
|
||||
compatible |= updateIfd(exifIfd_);
|
||||
compatible |= updateIfd(iopIfd_);
|
||||
compatible |= updateIfd(gpsIfd_);
|
||||
compatible |= updateIfd(ifd1_);
|
||||
|
||||
Ifd& ifd = ifd0_;
|
||||
return compatible;
|
||||
} // ExifData::updateIfds
|
||||
|
||||
bool ExifData::updateIfd(Ifd& ifd)
|
||||
{
|
||||
if (ifd.alloc()) throw Error("Invariant violated in ExifData::updateIfd");
|
||||
|
||||
bool compatible = true;
|
||||
Ifd::iterator end = ifd.end();
|
||||
for (Ifd::iterator entry = ifd.begin(); entry != end; ++entry) {
|
||||
|
||||
// find the corresponding metadatum
|
||||
std::string key = ExifTags::makeKey(entry->tag(), entry->ifdId());
|
||||
|
||||
const_iterator md = findKey(key);
|
||||
if (md == this->end()) {
|
||||
// corresponding metadatum was deleted: this is not (yet) a
|
||||
@ -1424,9 +1444,8 @@ std::cout << "->>>>>> writing from metadata <<<<<<-\n";
|
||||
}
|
||||
entry->setValue(md->value(), byteOrder());
|
||||
}
|
||||
|
||||
return compatible;
|
||||
}
|
||||
} // ExifData::updateIfd
|
||||
|
||||
bool ExifData::compatible() const
|
||||
{
|
||||
|
||||
31
src/exif.hpp
31
src/exif.hpp
@ -21,7 +21,7 @@
|
||||
/*!
|
||||
@file exif.hpp
|
||||
@brief Encoding and decoding of %Exif data
|
||||
@version $Name: $ $Revision: 1.17 $
|
||||
@version $Name: $ $Revision: 1.18 $
|
||||
@author Andreas Huggel (ahu)
|
||||
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
|
||||
@date 09-Jan-04, ahu: created
|
||||
@ -784,10 +784,22 @@ namespace Exif {
|
||||
class Ifd {
|
||||
public:
|
||||
/*!
|
||||
@brief Constructor. Allows to set the IFD identifier and choose
|
||||
whether or not memory management is required for the Entries.
|
||||
@brief Constructor. Allows to set the IFD identifier. Memory management
|
||||
is enabled, offset is set to 0. Serves as default constructor.
|
||||
*/
|
||||
explicit Ifd(IfdId ifdId =ifdIdNotSet, uint32 offset =0, bool alloc =true);
|
||||
explicit Ifd(IfdId ifdId =ifdIdNotSet);
|
||||
/*!
|
||||
@brief Constructor. Allows to set the IFD identifier and the offset of
|
||||
the IFD from the start of TIFF header. Memory management is
|
||||
enabled.
|
||||
*/
|
||||
Ifd(IfdId ifdId, uint32 offset);
|
||||
/*!
|
||||
@brief Constructor. Allows to set the IFD identifier, offset of the
|
||||
IFD from the start of TIFF header and choose whether or not
|
||||
memory management is required for the Entries.
|
||||
*/
|
||||
Ifd(IfdId ifdId, uint32 offset, bool alloc);
|
||||
|
||||
//! Entries const iterator type
|
||||
typedef Entries::const_iterator const_iterator;
|
||||
@ -904,6 +916,8 @@ namespace Exif {
|
||||
long offset() const { return offset_; }
|
||||
//! Get the offset to the next IFD from the start of the TIFF header
|
||||
long next() const { return next_; }
|
||||
//! Get the memory allocation mode
|
||||
bool alloc() const { return alloc_; }
|
||||
//@}
|
||||
//! Get the size of this IFD in bytes (IFD only, without data)
|
||||
long size() const;
|
||||
@ -1046,6 +1060,10 @@ namespace Exif {
|
||||
|
||||
*/
|
||||
class ExifData {
|
||||
// Copying not allowed (Todo: implement me!)
|
||||
ExifData(const ExifData& rhs);
|
||||
// Assignment not allowed (Todo: implement me!)
|
||||
ExifData& operator=(const ExifData& rhs);
|
||||
public:
|
||||
//! Default constructor
|
||||
ExifData();
|
||||
@ -1179,6 +1197,11 @@ namespace Exif {
|
||||
modified in this case.
|
||||
*/
|
||||
bool updateIfds();
|
||||
/*
|
||||
Update the metadata of one IFD. Called by updateIfds() for each
|
||||
of the internal IFDs.
|
||||
*/
|
||||
bool updateIfd(Ifd& ifd);
|
||||
/*
|
||||
Check if the metadata is compatible with the internal IFDs for
|
||||
non-intrusive writing. Return true if compatible, false if not.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user