Exiv2
pngimage.hpp
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2021 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
20 #ifndef PNGIMAGE_HPP_
21 #define PNGIMAGE_HPP_
22 
23 // *****************************************************************************
24 #include "exiv2lib_export.h"
25 
26 // included header files
27 #include "image.hpp"
28 
29 // *****************************************************************************
30 // namespace extensions
31 namespace Exiv2
32 {
33 
34 // *****************************************************************************
35 // class definitions
36 
37  // Add PNG to the supported image formats
38  namespace ImageType
39  {
40  const int png = 6;
41  }
42 
47  class EXIV2API PngImage : public Image {
48  public:
50 
51 
66  PngImage(BasicIo::AutoPtr io, bool create);
68 
70 
71  void readMetadata();
72  void writeMetadata();
73 
80  void printStructure(std::ostream& out, PrintStructureOption option,int depth);
82 
84 
85  std::string mimeType() const;
87 
88  private:
90 
91  PngImage(const PngImage& rhs);
94  PngImage& operator=(const PngImage& rhs);
102  void doWriteMetadata(BasicIo& oIo);
104 
105  std::string profileName_;
106 
107  }; // class PngImage
108 
109 // *****************************************************************************
110 // template, inline and free functions
111 
112  // These could be static private functions on Image subclasses but then
113  // ImageFactory needs to be made a friend.
119  EXIV2API Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create);
120 
122  EXIV2API bool isPngType(BasicIo& iIo, bool advance);
123 
124 } // namespace Exiv2
125 
126 #endif // #ifndef PNGIMAGE_HPP_
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:258
Exiv2::Internal::indent
std::string indent(int32_t d)
indent output for kpsRecursive in printStructure() .
Definition: image_int.cpp:106
Exiv2::makeSlice
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:665
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::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:316
Exiv2::TiffParser::decode
static ByteOrder decode(ExifData &exifData, IptcData &iptcData, XmpData &xmpData, const byte *pData, uint32_t size)
Decode metadata from a buffer pData of length size with data in TIFF format to the provided metadata ...
Definition: tiffimage.cpp:248
Exiv2::PngImage::PngImage
PngImage(BasicIo::AutoPtr io, bool create)
Constructor that can either open an existing PNG image or create a new image from scratch....
Exiv2::Internal::binaryToString
binaryToStringHelper< T > binaryToString(const Slice< T > sl)
format binary data for display in Image::printStructure()
Definition: image_int.hpp:118
Exiv2::PngImage
Class to access PNG images. Exif and IPTC metadata are supported directly.
Definition: pngimage.hpp:47
Exiv2::ExifParser::encode
static WriteMethod encode(Blob &blob, const byte *pData, uint32_t size, ByteOrder byteOrder, const ExifData &exifData)
Encode Exif metadata from the provided metadata to binary Exif format.
Definition: exif.cpp:668
Exiv2::PngImage::mimeType
std::string mimeType() const
Return the MIME type of the image.
Exiv2::Internal::stringFormat
std::string stringFormat(const char *format,...)
format a string in the pattern of sprintf .
Definition: image_int.cpp:32
Exiv2::IptcData::printStructure
static void printStructure(std::ostream &out, const Slice< byte * > &bytes, uint32_t depth)
dump iptc formatted binary data (used by printStructure kpsRecursive)
Definition: iptc.cpp:347
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::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:260
Exiv2::XmpParser::encode
static int encode(std::string &xmpPacket, const XmpData &xmpData, uint16_t formatFlags=useCompactFormat, uint32_t padding=0)
Encode (serialize) XMP metadata from xmpData into a string xmpPacket. The XMP packet returned in the ...
Definition: xmp.cpp:1000
Exiv2::PngImage::writeMetadata
void writeMetadata()
Write metadata back to the image.
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::ul2Data
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:403
Exiv2::newPngInstance
EXIV2API Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create)
Create a new PngImage instance and return an auto-pointer to it. Caller owns the returned object and ...
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
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::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:81
Exiv2::PngImage::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Exiv2::Internal::PngChunk::keyTXTChunk
static DataBuf keyTXTChunk(const DataBuf &data, bool stripHeader=false)
Return PNG TXT chunk key as data buffer.
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
Exiv2::PngImage::printStructure
void printStructure(std::ostream &out, PrintStructureOption option, int depth)
Print out the structure of image file.
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition: image.hpp:64
EXV_ERROR
#define EXV_ERROR
Shorthand for a temp error log message object and return its ostringstream.
Definition: error.hpp:150
Exiv2::ImageType::png
const int png
PNG image type (see class PngImage)
Definition: pngimage.hpp:40
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::Photoshop::setIptcIrb
static DataBuf setIptcIrb(const byte *pPsData, long sizePsData, const IptcData &iptcData)
Set the new IPTC IRB, keeps existing IRBs but removes the IPTC block if there is no new IPTC data to ...
Definition: jpgimage.cpp:249
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
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::getULong
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:278
error.hpp
Error class for exceptions, log message class.
Exiv2::Blob
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:151
Exiv2::isPngType
EXIV2API bool isPngType(BasicIo &iIo, bool advance)
Check if the file iIo is a PNG image.