Exiv2
Loading...
Searching...
No Matches
pngchunk_int.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef PNGCHUNK_INT_HPP_
4#define PNGCHUNK_INT_HPP_
5
6// *****************************************************************************
7// included header files
8#include "pngimage.hpp"
9#include "types.hpp"
10
11// *****************************************************************************
12// namespace extensions
13namespace Exiv2::Internal {
14// *****************************************************************************
15// class definitions
16
21class PngChunk {
22 public:
26 enum TxtChunkType { tEXt_Chunk = 0, zTXt_Chunk = 1, iTXt_Chunk = 2 };
27
36 static void decodeIHDRChunk(const DataBuf& data, uint32_t* outWidth, uint32_t* outHeight);
37
46 static void decodeTXTChunk(Image* pImage, const DataBuf& data, TxtChunkType type);
47
55 static DataBuf decodeTXTChunk(const DataBuf& data, TxtChunkType type);
56
63 static DataBuf keyTXTChunk(const DataBuf& data, bool stripHeader = false);
64
73 static std::string makeMetadataChunk(const std::string& metadata, MetadataId type);
74
75 private:
80 static DataBuf parseTXTChunk(const DataBuf& data, size_t keysize, TxtChunkType type);
81
91 static void parseChunkContent(Image* pImage, const byte* key, size_t keySize, const DataBuf& arr);
92
103 static std::string makeAsciiTxtChunk(const std::string& keyword, const std::string& text, bool compress);
104
113 static std::string makeUtf8TxtChunk(const std::string& keyword, const std::string& text, bool compress);
114
118 static void zlibUncompress(const byte* compressedText, unsigned int compressedTextSize, DataBuf& arr);
119
123 static std::string zlibCompress(const std::string& text);
124
128 static DataBuf readRawProfile(const DataBuf& text, bool iTXt);
129
134 static std::string writeRawProfile(const std::string& profileData, const char* profileType);
135
136 friend class Exiv2::PngImage;
137
138}; // class PngChunk
139
140} // namespace Exiv2::Internal
141
142#endif // #ifndef PNGCHUNK_INT_HPP_
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:50
Stateless parser class for data in PNG chunk format. Images use this class to decode and encode PNG-b...
Definition pngchunk_int.hpp:21
static void decodeIHDRChunk(const DataBuf &data, uint32_t *outWidth, uint32_t *outHeight)
Decode PNG IHDR chunk data from a data buffer data and return image size to outWidth and outHeight.
static DataBuf decodeTXTChunk(const DataBuf &data, TxtChunkType type)
Decode PNG tEXt, zTXt, or iTXt chunk data from pImage passed by data buffer data and extract Comment,...
static DataBuf keyTXTChunk(const DataBuf &data, bool stripHeader=false)
Return PNG TXT chunk key as data buffer.
TxtChunkType
Text Chunk types.
Definition pngchunk_int.hpp:26
static void decodeTXTChunk(Image *pImage, const DataBuf &data, TxtChunkType type)
Decode PNG tEXt, zTXt, or iTXt chunk data from pImage passed by data buffer data and extract Comment,...
static std::string makeMetadataChunk(const std::string &metadata, MetadataId type)
Return a complete PNG chunk data compressed or not as buffer. Data returned is formatted accordingly ...
Class to access PNG images. Exif and IPTC metadata are supported directly.
Definition pngimage.hpp:22
Helper structure for the Matroska tags lookup table.
Definition matroskavideo.hpp:39
MetadataId
An identifier for each type of metadata.
Definition types.hpp:47
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124