Parsing few more tags
This commit is contained in:
parent
a467b687dc
commit
4752b4d6b2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
|
||||
43
TIFF.cpp
43
TIFF.cpp
@ -2,6 +2,8 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
static const std::map<TiffTag, std::string> tagDescriptions = {
|
||||
{NEW_SUBFILE_TYPE, "New subfile type"},
|
||||
@ -26,7 +28,14 @@ static const std::map<TiffTag, std::string> tagDescriptions = {
|
||||
{DATE_TIME, "Date/Time"},
|
||||
{XML_PACKET, "XML Packet"},
|
||||
{CFA_REPEAT_PATTERN_DIM, "CFA repeat pattern"},
|
||||
{CFA_PATTERN, "CFA pattern"}
|
||||
{CFA_PATTERN, "CFA pattern"},
|
||||
{EXPOSURE_TIME, "Exposure time (seconds)"},
|
||||
{F_NUMBER, "F-Number (relative aperture)"},
|
||||
{EXIF_IFD, "EXIF IFD offset"},
|
||||
{ISO_SPEED_RATINGS, "ISO"},
|
||||
{DATE_TIME_ORIGINAL, "Date/time original"},
|
||||
{FOCAL_LENGTH, "Focal length (mm)"},
|
||||
{TIFF_EP_STANDARD_ID, "TIFF/EP standard ID"}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, Compression compression) {
|
||||
@ -48,7 +57,7 @@ std::ostream& operator<<(std::ostream& stream, PhotometricInterpretation pr) {
|
||||
case PALETTE_COLOR: stream << "palette color"; break;
|
||||
case TRANSPARENCY_MASK: stream << "transparency mask"; break;
|
||||
case YCBCR: stream << "YCbCr (YUV)"; break;
|
||||
case COLOR_FILTER_ARRAY: stream << "color filter array"; break;
|
||||
case COLOR_FILTER_ARRAY: stream << "CFA (color filter array)"; break;
|
||||
case LINEAR_RAW: stream << "linear raw"; break;
|
||||
default: stream << "undefined"; break;
|
||||
}
|
||||
@ -57,7 +66,7 @@ std::ostream& operator<<(std::ostream& stream, PhotometricInterpretation pr) {
|
||||
}
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& stream, const RationalType<T>& rational) {
|
||||
stream << std::to_string(rational.numerator) + "/" + std::to_string(rational.denominator);
|
||||
stream << 1.0*rational.numerator/rational.denominator;
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -98,7 +107,17 @@ 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) {
|
||||
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);
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -107,6 +126,23 @@ std::ostream& operator<<(std::ostream& stream, const std::vector<CFAPatternDim>&
|
||||
return stream;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, const std::vector<CFAPattern>& vector) {
|
||||
std::string pattern;
|
||||
for(auto filter: vector) {
|
||||
switch (filter) {
|
||||
case RED: pattern += "R"; break;
|
||||
case GREEN: pattern += "G"; break;
|
||||
case BLUE: pattern += "B"; break;
|
||||
case CYAN: pattern += "C"; break;
|
||||
case MAGENTA: pattern += "M"; break;
|
||||
case YELLOW: pattern += "Y"; break;
|
||||
case WHITE: pattern += "W"; break;
|
||||
}
|
||||
}
|
||||
stream << pattern;
|
||||
return stream;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ImageFileDirectory::parseValueImpl(char *filePtr, IfdEntry *entry) {
|
||||
size_t sizeOfValue = sizeOfType(entry->type)*entry->numberOfValues;
|
||||
@ -132,6 +168,7 @@ void ImageFileDirectory::parseValue(char *filePtr, IfdEntry *entry) {
|
||||
case ORIENTATION: parseValueImpl<Orientation>(filePtr, entry); break;
|
||||
case PLANAR_CONFIGURATION: parseValueImpl<PlanarConfiguration>(filePtr, entry); break;
|
||||
case CFA_REPEAT_PATTERN_DIM: parseValueImpl<CFAPatternDim>(filePtr, entry); break;
|
||||
case CFA_PATTERN: parseValueImpl<CFAPattern>(filePtr, entry); break;
|
||||
default: parseValueImpl<T>(filePtr, entry); break;
|
||||
}
|
||||
}
|
||||
|
||||
23
TIFF.h
23
TIFF.h
@ -53,7 +53,14 @@ enum TiffTag: uint16_t {
|
||||
DATE_TIME = 0x132,
|
||||
XML_PACKET = 0x2BC,
|
||||
CFA_REPEAT_PATTERN_DIM = 0x828D,
|
||||
CFA_PATTERN = 0x828E
|
||||
CFA_PATTERN = 0x828E,
|
||||
EXPOSURE_TIME = 0x829A,
|
||||
F_NUMBER = 0x829D,
|
||||
EXIF_IFD = 0x8769,
|
||||
ISO_SPEED_RATINGS = 0x8827,
|
||||
DATE_TIME_ORIGINAL = 0x9003,
|
||||
FOCAL_LENGTH = 0x920A,
|
||||
TIFF_EP_STANDARD_ID = 0x9216
|
||||
|
||||
};
|
||||
|
||||
@ -117,7 +124,17 @@ struct RationalType {
|
||||
|
||||
using Rational = RationalType<uint32_t>;
|
||||
using SRational = RationalType<int32_t>;
|
||||
typedef uint16_t CFAPatternDim;
|
||||
|
||||
enum CFAPatternDim: uint16_t {};
|
||||
enum CFAPattern: uint8_t {
|
||||
RED = 0,
|
||||
GREEN = 1,
|
||||
BLUE = 2,
|
||||
CYAN = 3,
|
||||
MAGENTA = 4,
|
||||
YELLOW = 5,
|
||||
WHITE = 6
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, Compression compression);
|
||||
std::ostream& operator<<(std::ostream& stream, PhotometricInterpretation pr);
|
||||
@ -133,6 +150,8 @@ public:
|
||||
Compression, PhotometricInterpretation, std::vector<Compression>, std::vector<PhotometricInterpretation>,
|
||||
ResolutionUnit, std::vector<ResolutionUnit>, Orientation, std::vector<Orientation>,
|
||||
PlanarConfiguration, std::vector<PlanarConfiguration>,
|
||||
CFAPatternDim, std::vector<CFAPatternDim>,
|
||||
CFAPattern, std::vector<CFAPattern>,
|
||||
std::vector<uint8_t>, std::vector<uint16_t>, std::vector<uint32_t>, std::vector<Rational>,
|
||||
std::vector<int8_t>, std::vector<int16_t>, std::vector<int32_t>, std::vector<SRational>,
|
||||
std::vector<float>, std::vector<double>>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user