pngchunk_int.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PNGCHUNK_INT_HPP_
#define PNGCHUNK_INT_HPP_
// *****************************************************************************
// included header files
#include "types.hpp"
#include "pngimage.hpp"
// + standard includes
#include <iosfwd>
#include <cassert>
#include <cstdarg>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class declarations
class Image;
namespace Internal {
// *****************************************************************************
// class definitions
class PngChunk {
public:
enum TxtChunkType {
tEXt_Chunk = 0,
zTXt_Chunk = 1,
iTXt_Chunk = 2
};
public:
static void decodeIHDRChunk(const DataBuf& data,
int* outWidth,
int* outHeight);
static void decodeTXTChunk(Image* pImage,
const DataBuf& data,
TxtChunkType type);
static DataBuf decodeTXTChunk(const DataBuf& data,
TxtChunkType type);
static DataBuf keyTXTChunk(const DataBuf& data, bool stripHeader=false);
static std::string makeMetadataChunk(const std::string& metadata,
MetadataId type);
private:
static DataBuf parseTXTChunk(const DataBuf& data,
int keysize,
TxtChunkType type);
static void parseChunkContent( Image* pImage,
const byte* key,
long keySize,
const DataBuf arr);
static std::string makeAsciiTxtChunk(const std::string& keyword,
const std::string& text,
bool compress);
static std::string makeUtf8TxtChunk(const std::string& keyword,
const std::string& text,
bool compress);
static void zlibUncompress(const byte* compressedText,
unsigned int compressedTextSize,
DataBuf& arr);
static std::string zlibCompress(const std::string& text);
static DataBuf readRawProfile(const DataBuf& text,bool iTXt);
static std::string writeRawProfile(const std::string& profileData,
const char* profileType);
friend class Exiv2::PngImage;
}; // class PngChunk
}} // namespace Internal, Exiv2
#endif // #ifndef PNGCHUNK_INT_HPP_
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:78
Exiv2::Internal::PngChunk
Stateless parser class for data in PNG chunk format. Images use this class to decode and encode PNG-b...
Definition: pngchunk_int.hpp:50
Exiv2::Internal::PngChunk::decodeTXTChunk
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,...
Exiv2::Internal::PngChunk::decodeIHDRChunk
static void decodeIHDRChunk(const DataBuf &data, int *outWidth, int *outHeight)
Decode PNG IHDR chunk data from a data buffer data and return image size to outWidth and outHeight.
Exiv2::Internal::PngChunk::keyTXTChunk
static DataBuf keyTXTChunk(const DataBuf &data, bool stripHeader=false)
Return PNG TXT chunk key as data buffer.
Exiv2::Internal::PngChunk::TxtChunkType
TxtChunkType
Text Chunk types.
Definition: pngchunk_int.hpp:55
Exiv2::Internal::PngChunk::decodeTXTChunk
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,...
Exiv2::Internal::PngChunk::makeMetadataChunk
static std::string makeMetadataChunk(const std::string &metadata, MetadataId type)
Return a complete PNG chunk data compressed or not as buffer. Data returned is formated accordingly w...
Exiv2::PngImage
Class to access PNG images. Exif and IPTC metadata are supported directly.
Definition: pngimage.hpp:47
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::MetadataId
MetadataId
An identifier for each type of metadata.
Definition: types.hpp:108