From 0a74bc8b34b8327f93bdb7d07a37fd9311e5db08 Mon Sep 17 00:00:00 2001 From: selim mustafaev Date: Fri, 14 Sep 2018 00:27:37 +0300 Subject: [PATCH] All necessary tags completed --- TIFF.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++------ TIFF.h | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/TIFF.cpp b/TIFF.cpp index 7e4748b..8283e88 100644 --- a/TIFF.cpp +++ b/TIFF.cpp @@ -5,6 +5,7 @@ #include #include #include +#include static const std::map tagDescriptions = { {NEW_SUBFILE_TYPE, "New subfile type"}, @@ -37,7 +38,33 @@ static const std::map tagDescriptions = { {DATE_TIME_ORIGINAL, "Date/time original"}, {FOCAL_LENGTH, "Focal length (mm)"}, {TIFF_EP_STANDARD_ID, "TIFF/EP standard ID"}, - {COPYRIGHT_NOTICE, "Copyright notice"} + {COPYRIGHT_NOTICE, "Copyright notice"}, + {DNG_VERSION, "DNG version"}, + {DNG_BACKWARD_VERSION, "DNG backward version"}, + {UNIQUE_CAMERA_MODEL, "Unique camera model"}, + {CFA_PLANE_COLOR, "CFA plane color"}, + {CFA_LAYOUT, "CFA spatial layout"}, + {BLACK_LEVEL_REPEAT_DIM, "Black level repeat pattern size"}, + {BLACK_LEVEL, "Black level"}, + {WHITE_LEVEL, "White level"}, + {DEFAULT_SCALE, "Default scale"}, + {DEFAULT_CROP_ORIGIN, "Default crop origin"}, + {DEFAULT_CROP_SIZE, "Default crop size"}, + {COLOR_MATRIX_1, "Color matrix 1"}, + {COLOR_MATRIX_2, "Color matrix 2"}, + {CAMERA_CALIBRATION_1, "Camera calibration 1"}, + {CAMERA_CALIBRATION_2, "Camera calibration 2"}, + {AS_SHOT_NEUTRAL, "White balance at time of capture"}, + {BASELINE_EXPOSURE, "Baseline exposure (EV units)"}, + {CALIBRATION_ILLUMINANT_1, "Calibration illuminant 1"}, + {CALIBRATION_ILLUMINANT_2, "Calibration illuminant 2"}, + {ACTIVE_AREA, "Active area of sensor (pixels)"}, + {FORWARD_MATRIX_1, "Forward matrix 1"}, + {FORWARD_MATRIX_2, "Forward matrix 2"}, + {OPCODE_LIST_1, "Opcode list 1"}, + {OPCODE_LIST_2, "Opcode list 2"}, + {OPCODE_LIST_3, "Opcode list 3"}, + {NOISE_PROFILE, "Noise profile"} }; std::ostream &operator<<(std::ostream &stream, Compression compression) { @@ -107,6 +134,27 @@ std::ostream& operator<<(std::ostream& stream, PlanarConfiguration conf) { return stream; } +std::ostream& operator<<(std::ostream& stream, CFALayout layout) { + switch (layout) { + case RECTANGULAR: stream << "rectangular"; break; + case STAGGERED_LAYOUT_A: stream << "even columns are offset down by 1/2 row"; break; + case STAGGERED_LAYOUT_B: stream << "even columns are offset up by 1/2 row"; break; + case STAGGERED_LAYOUT_C: stream << "even rows are offset right by 1/2 column"; break; + case STAGGERED_LAYOUT_D: stream << "even rows are offset left by 1/2 column"; break; + case STAGGERED_LAYOUT_E: stream << "even rows are offset up by 1/2 row, even columns are offset left by 1/2 column"; break; + case STAGGERED_LAYOUT_F: stream << "even rows are offset up by 1/2 row, even columns are offset right by 1/2 column"; break; + case STAGGERED_LAYOUT_G: stream << "even rows are offset down by 1/2 row, even columns are offset left by 1/2 column"; break; + case STAGGERED_LAYOUT_H: stream << "even rows are offset down by 1/2 row, even columns are offset right by 1/2 column"; break; + } + + return stream; +} + +std::ostream& operator<<(std::ostream& stream, uint8_t value) { + stream << (int)value; + return stream; +} + template std::ostream& operator<<(std::ostream& stream, const std::vector& vector) { size_t vSize = vector.size(); @@ -117,7 +165,7 @@ std::ostream& operator<<(std::ostream& stream, const std::vector& vector) { std::stringstream ss; ss << std::setw(0) << "["; for(size_t i = 0; i < vSize; ++i) { - ss << vector[i]; + ss << vector[i]; if(i < vSize - 1) { ss << ", "; } @@ -176,6 +224,7 @@ void ImageFileDirectory::parseValue(char *filePtr, IfdEntry *entry) { case PLANAR_CONFIGURATION: parseValueImpl(filePtr, entry); break; case CFA_REPEAT_PATTERN_DIM: parseValueImpl(filePtr, entry); break; case CFA_PATTERN: parseValueImpl(filePtr, entry); break; + case CFA_LAYOUT: parseValueImpl(filePtr, entry); break; default: parseValueImpl(filePtr, entry); break; } } @@ -241,16 +290,16 @@ std::optional ImageFileDirectory::operator[] } void ImageFileDirectory::dumpInfo() const { - std::cout << "=== IFD ====================================================================================================================" << std::endl; - std::cout << "| Tag | Description | Value |" << std::endl; - std::cout << "----------------------------------------------------------------------------------------------------------------------------" << std::endl; + std::cout << "=== IFD ====================================================================================================================================" << std::endl; + std::cout << "| Tag | Description | Value |" << std::endl; + std::cout << "---------------------------------------------------------------------------------------------------------------------------------------------" << std::endl; std::ios state(nullptr); state.copyfmt(std::cout); for(auto const& [key, val]: _entriesMap) { std::visit([key](auto&& arg) { auto iter = tagDescriptions.find(key); std::string description = iter != tagDescriptions.end() ? iter->second : ""; - std::cout << "| " << std::left << std::setw(5) << key << " | " << std::setw(29) << description << " | " << std::setw(80) << arg << " |" << std::endl; + std::cout << "| " << std::left << std::setw(5) << key << " | " << std::setw(32) << description << " | " << std::setw(94) << arg << " |" << std::endl; }, val); } std::cout.copyfmt(state); diff --git a/TIFF.h b/TIFF.h index 36524e6..41c5a47 100644 --- a/TIFF.h +++ b/TIFF.h @@ -61,8 +61,33 @@ enum TiffTag: uint16_t { ISO_SPEED_RATINGS = 0x8827, DATE_TIME_ORIGINAL = 0x9003, FOCAL_LENGTH = 0x920A, - TIFF_EP_STANDARD_ID = 0x9216 - + TIFF_EP_STANDARD_ID = 0x9216, + DNG_VERSION = 0xC612, + DNG_BACKWARD_VERSION = 0xC613, + UNIQUE_CAMERA_MODEL = 0xC614, + CFA_PLANE_COLOR = 0xC616, + CFA_LAYOUT = 0xC617, + BLACK_LEVEL_REPEAT_DIM = 0xC619, + BLACK_LEVEL = 0xC61A, + WHITE_LEVEL = 0xC61D, + DEFAULT_SCALE = 0xC61E, + DEFAULT_CROP_ORIGIN = 0xC61F, + DEFAULT_CROP_SIZE = 0xC620, + COLOR_MATRIX_1 = 0xC621, + COLOR_MATRIX_2 = 0xC622, + CAMERA_CALIBRATION_1 = 0xC623, + CAMERA_CALIBRATION_2 = 0xC624, + AS_SHOT_NEUTRAL = 0xC628, + BASELINE_EXPOSURE = 0xC62A, + CALIBRATION_ILLUMINANT_1 = 0xC65A, + CALIBRATION_ILLUMINANT_2 = 0xC65B, + ACTIVE_AREA = 0xC68D, + FORWARD_MATRIX_1 = 0xC714, + FORWARD_MATRIX_2 = 0xC715, + OPCODE_LIST_1 = 0xC740, + OPCODE_LIST_2 = 0xC741, + OPCODE_LIST_3 = 0xC74E, + NOISE_PROFILE = 0xC761 }; enum PhotometricInterpretation: uint16_t { @@ -137,6 +162,18 @@ enum CFAPattern: uint8_t { WHITE = 6 }; +enum CFALayout: uint16_t { + RECTANGULAR = 1, + STAGGERED_LAYOUT_A = 2, + STAGGERED_LAYOUT_B = 3, + STAGGERED_LAYOUT_C = 4, + STAGGERED_LAYOUT_D = 5, + STAGGERED_LAYOUT_E = 6, + STAGGERED_LAYOUT_F = 7, + STAGGERED_LAYOUT_G = 8, + STAGGERED_LAYOUT_H = 9 +}; + std::ostream& operator<<(std::ostream& stream, Compression compression); std::ostream& operator<<(std::ostream& stream, PhotometricInterpretation pr); template std::ostream& operator<<(std::ostream& stream, const RationalType& rational); @@ -153,6 +190,7 @@ public: PlanarConfiguration, std::vector, CFAPatternDim, std::vector, CFAPattern, std::vector, + CFALayout, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector>;