#pragma once #include "CyclicRedundancyChecker.h" #include #include namespace Png { inline unsigned char getHighBitCheck() { return 0x89; } inline std::vector getSignature() { return {13, 10, 26, 10}; } inline std::string getName() { return "PNG"; } struct IHDRChunk { uint32_t width{0}; uint32_t height{0}; unsigned char bitDepth{0}; unsigned char colorType{0}; unsigned char compressionMethod{0}; unsigned char filterMethod{0}; unsigned char interlaceMethod{0}; std::string name{"IHDR"}; std::vector mData; std::string toString() const { std::stringstream sstr; sstr << "width: " << width << "\n"; sstr << "height: " << height << "\n"; sstr << "bitDepth: " << (int)bitDepth << "\n"; sstr << "colorType: " << (int)colorType << "\n"; sstr << "compressionMethod: " << (int)compressionMethod << "\n"; sstr << "filterMethod: " << (int)filterMethod << "\n"; sstr << "interlaceMethod: " << (int)interlaceMethod << "\n"; return sstr.str(); } uint32_t getLength() const { return 13; } void updateData() { mData.clear(); unsigned num_bytes = sizeof(uint32_t); for(unsigned idx=0; idx char_data = StringUtils::toBytes(name); std::copy(mData.begin(), mData.end(), std::back_inserter(char_data)); auto result = crc_check.doCrc(char_data.data(), char_data.size()); return result; } }; }