Exiv2
pngimage.hpp
Go to the documentation of this file.
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 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  */
31 #ifndef PNGIMAGE_HPP_
32 #define PNGIMAGE_HPP_
33 
34 // *****************************************************************************
35 #include "exiv2lib_export.h"
36 
37 // included header files
38 #include "image.hpp"
39 
40 // *****************************************************************************
41 // namespace extensions
42 namespace Exiv2
43 {
44 
45 // *****************************************************************************
46 // class definitions
47 
48  // Add PNG to the supported image formats
49  namespace ImageType
50  {
51  const int png = 6;
52  }
53 
58  class EXIV2API PngImage : public Image {
59  public:
61 
62 
77  PngImage(BasicIo::AutoPtr io, bool create);
79 
81 
82  void readMetadata();
83  void writeMetadata();
84 
91  void printStructure(std::ostream& out, PrintStructureOption option,int depth);
93 
95 
98 
99  private:
101 
102  PngImage(const PngImage& rhs);
105  PngImage& operator=(const PngImage& rhs);
113  void doWriteMetadata(BasicIo& oIo);
115 
116  std::string profileName_;
117 
118  }; // class PngImage
119 
120 // *****************************************************************************
121 // template, inline and free functions
122 
123  // These could be static private functions on Image subclasses but then
124  // ImageFactory needs to be made a friend.
130  EXIV2API Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create);
131 
133  EXIV2API bool isPngType(BasicIo& iIo, bool advance);
134 
135 } // namespace Exiv2
136 
137 #endif // #ifndef PNGIMAGE_HPP_
image_int.hpp
Internal image helpers.
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
Exiv2::Internal::indent
std::string indent(int32_t d)
indent output for kpsRecursive in printStructure() .
Definition: image_int.cpp:106
types.hpp
Type definitions for Exiv2 and related functionality.
Exiv2::makeSlice
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:673
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:356
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:125
Exiv2::PngImage
Class to access PNG images. Exif and IPTC metadata are supported directly.
Definition: pngimage.hpp:58
enforce.hpp
Port of D's enforce() to C++ & Exiv2.
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:653
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:351
enforce
void enforce(bool condition, const T &arg1)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition: enforce.hpp:43
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:271
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:836
Exiv2::PngImage::writeMetadata
void writeMetadata()
Write metadata back to the image.
pngchunk_int.hpp
Class PngChunk to parse PNG chunk data implemented using the following references: PNG iTXt chunk st...
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
image.hpp
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:408
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::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:84
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.
pngimage.hpp
PNG image, implemented using the following references: PNG specification by W3C PNG tags list by Phi...
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:323
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
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:67
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:51
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:239
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:81
futils.hpp
Basic file utility functions required by Exiv2.
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:283
error.hpp
Error class for exceptions, log message class.
Exiv2::Blob
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:162
jpgimage.hpp
Class JpegImage to access JPEG images.
Exiv2::isPngType
EXIV2API bool isPngType(BasicIo &iIo, bool advance)
Check if the file iIo is a PNG image.