diff --git a/TIFF.cpp b/TIFF.cpp index 7d10d7a..7e4748b 100644 --- a/TIFF.cpp +++ b/TIFF.cpp @@ -4,6 +4,7 @@ #include #include #include +#include static const std::map tagDescriptions = { {NEW_SUBFILE_TYPE, "New subfile type"}, @@ -35,7 +36,8 @@ static const std::map tagDescriptions = { {ISO_SPEED_RATINGS, "ISO"}, {DATE_TIME_ORIGINAL, "Date/time original"}, {FOCAL_LENGTH, "Focal length (mm)"}, - {TIFF_EP_STANDARD_ID, "TIFF/EP standard ID"} + {TIFF_EP_STANDARD_ID, "TIFF/EP standard ID"}, + {COPYRIGHT_NOTICE, "Copyright notice"} }; std::ostream &operator<<(std::ostream &stream, Compression compression) { @@ -107,17 +109,22 @@ std::ostream& operator<<(std::ostream& stream, PlanarConfiguration conf) { template std::ostream& operator<<(std::ostream& stream, const std::vector& vector) { - std::ios_base::fmtflags f(stream.flags()); - if(vector.size() > 10) { + size_t vSize = vector.size(); + if(vSize > 10) { stream << " (" + std::to_string(vector.size()) + ")"; - } else { - stream << std::setw(0) << "[" << vector[0]; - std::accumulate(std::next(vector.begin()), vector.end(), std::string(), [&stream](std::string a, T elem){ - stream << ", " << elem; - }); - stream << "]"; } - stream.flags(f); + else { + std::stringstream ss; + ss << std::setw(0) << "["; + for(size_t i = 0; i < vSize; ++i) { + ss << vector[i]; + if(i < vSize - 1) { + ss << ", "; + } + } + ss << "]"; + stream << ss.str(); + } return stream; } @@ -182,7 +189,11 @@ ImageFileDirectory::ImageFileDirectory(char* ptr, char* filePtr) { auto entry = _entries[i]; switch (entry.type) { - case ASCII: _entriesMap.emplace(entry.tag, EntryValueType(std::string(filePtr + entry.valueOrOffset))); break; + case ASCII: { + auto str = entry.numberOfValues > 1 ? std::string(filePtr + entry.valueOrOffset) : std::string(); + _entriesMap.emplace(entry.tag, EntryValueType(str)); + break; + } case BYTE: parseValue(filePtr, &entry); break; case SHORT: parseValue(filePtr, &entry); break; case LONG: parseValue(filePtr, &entry); break; diff --git a/TIFF.h b/TIFF.h index afc2e96..36524e6 100644 --- a/TIFF.h +++ b/TIFF.h @@ -54,6 +54,7 @@ enum TiffTag: uint16_t { XML_PACKET = 0x2BC, CFA_REPEAT_PATTERN_DIM = 0x828D, CFA_PATTERN = 0x828E, + COPYRIGHT_NOTICE = 0x8298, EXPOSURE_TIME = 0x829A, F_NUMBER = 0x829D, EXIF_IFD = 0x8769,