small fixes

This commit is contained in:
Selim Mustafaev 2018-09-13 19:43:34 +03:00
parent 4752b4d6b2
commit 779f9d9bab
2 changed files with 23 additions and 11 deletions

View File

@ -4,6 +4,7 @@
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <sstream>
static const std::map<TiffTag, std::string> tagDescriptions = {
{NEW_SUBFILE_TYPE, "New subfile type"},
@ -35,7 +36,8 @@ static const std::map<TiffTag, std::string> 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<typename T>
std::ostream& operator<<(std::ostream& stream, const std::vector<T>& vector) {
std::ios_base::fmtflags f(stream.flags());
if(vector.size() > 10) {
size_t vSize = vector.size();
if(vSize > 10) {
stream << "<vector> (" + 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<uint8_t>(filePtr, &entry); break;
case SHORT: parseValue<uint16_t>(filePtr, &entry); break;
case LONG: parseValue<uint32_t>(filePtr, &entry); break;

1
TIFF.h
View File

@ -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,