Exiv2
pgfimage.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  */
30 #ifndef PGFIMAGE_HPP_
31 #define PGFIMAGE_HPP_
32 
33 // *****************************************************************************
34 #include "exiv2lib_export.h"
35 
36 // included header files
37 #include "image.hpp"
38 
39 // *****************************************************************************
40 // namespace extensions
41 namespace Exiv2
42 {
43 
44 // *****************************************************************************
45 // class definitions
46 
47  // Add PGF to the supported image formats
48  namespace ImageType
49  {
50  const int pgf = 17;
51  }
52 
57  class EXIV2API PgfImage : public Image {
58  public:
60 
61 
76  PgfImage(BasicIo::AutoPtr io, bool create);
78 
80 
81  void readMetadata();
82  void writeMetadata();
84 
86 
87  std::string mimeType() const { return "image/pgf"; }
89 
90  private:
91  bool bSwap_; // true for bigEndian hardware, else false
93 
94  PgfImage(const PgfImage& rhs);
97  PgfImage& operator=(const PgfImage& rhs);
105  void doWriteMetadata(BasicIo& oIo);
107  byte readPgfMagicNumber(BasicIo& iIo);
109  uint32_t readPgfHeaderSize(BasicIo& iIo);
111  DataBuf readPgfHeaderStructure(BasicIo& iIo, int& width,int & height);
113 
114  }; // class PgfImage
115 
116 // *****************************************************************************
117 // template, inline and free functions
118 
119  // These could be static private functions on Image subclasses but then
120  // ImageFactory needs to be made a friend.
126  EXIV2API Image::AutoPtr newPgfInstance(BasicIo::AutoPtr io, bool create);
127 
129  EXIV2API bool isPgfType(BasicIo& iIo, bool advance);
130 
131 } // namespace Exiv2
132 
133 #endif // #ifndef PGFIMAGE_HPP_
Exiv2::MemIo
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:540
Exiv2::ImageType::pgf
const int pgf
PGF image type (see class PgfImage)
Definition: pgfimage.hpp:50
Exiv2::BasicIo::isopen
virtual bool isopen() const =0
Returns true if the IO source is open, otherwise false.
Exiv2::BasicIo::error
virtual int error() const =0
Returns 0 if the IO source is in a valid state, otherwise nonzero.
Exiv2::DataBuf::pData_
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
Exiv2::Image::iptcData_
IptcData iptcData_
IPTC data container.
Definition: image.hpp:489
Exiv2::IoCloser
Utility class that closes a BasicIo instance upon destruction. Meant to be used as a stack variable i...
Definition: basicio.hpp:264
Exiv2::PgfImage::writeMetadata
void writeMetadata()
Write metadata back to the image.
Definition: pgfimage.cpp:160
Exiv2::strError
EXIV2API std::string strError()
Return a system error message and the error code (errno). See strerror(3).
Definition: futils.cpp:352
Exiv2::Image::exifData_
ExifData exifData_
Exif data container.
Definition: image.hpp:488
Exiv2::isPgfType
EXIV2API bool isPgfType(BasicIo &iIo, bool advance)
Check if the file iIo is a PGF image.
Definition: pgfimage.cpp:333
Exiv2::PgfImage::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition: pgfimage.cpp:107
Exiv2::Image::pixelHeight_
int pixelHeight_
image pixel height
Definition: image.hpp:495
Exiv2::Image::clearMetadata
virtual void clearMetadata()
Erase all buffered metadata. Metadata is not removed from the actual image until the writeMetadata() ...
Definition: image.cpp:541
Exiv2::PgfImage::mimeType
std::string mimeType() const
Return the MIME type of the image.
Definition: pgfimage.hpp:87
enforce.hpp
Port of D's enforce() to C++ & Exiv2.
Exiv2::ImageFactory::open
static Image::AutoPtr open(const std::string &path, bool useCurl=true)
Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...
Definition: image.cpp:893
pgfimage.hpp
PGF image, implemented using the following references: PGF specification from libpgf web site
Exiv2::Image::pixelWidth_
int pixelWidth_
image pixel width
Definition: image.hpp:494
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::Image::xmpData
virtual XmpData & xmpData()
Returns an XmpData instance containing currently buffered XMP data.
Definition: image.cpp:561
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::BasicIo::putb
virtual int putb(byte data)=0
Write one byte to the IO source. Current IO position is advanced by one byte.
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:271
Exiv2::BasicIo::eof
virtual bool eof() const =0
Returns true if the IO position has reached the end, otherwise false.
Exiv2::BasicIo::read
virtual DataBuf read(long rcount)=0
Read data from the IO source. Reading starts at the current IO position and the position is advanced ...
Exiv2::PgfImage
Class to access PGF images. Exif and IPTC metadata are supported directly.
Definition: pgfimage.hpp:57
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::BasicIo::path
virtual std::string path() const =0
Return the path to the IO resource. Often used to form comprehensive error messages where only a Basi...
Exiv2::PgfImage::PgfImage
PgfImage(BasicIo::AutoPtr io, bool create)
Constructor that can either open an existing PGF image or create a new image from scratch....
Definition: pgfimage.cpp:85
Exiv2::newPgfInstance
EXIV2API Image::AutoPtr newPgfInstance(BasicIo::AutoPtr io, bool create)
Create a new PgfImage instance and return an auto-pointer to it. Caller owns the returned object and ...
Definition: pgfimage.cpp:323
Exiv2::BasicIo::write
virtual long write(const byte *data, long wcount)=0
Write data to the IO source. Current IO position is advanced by the number of bytes written.
Exiv2::Image::io_
BasicIo::AutoPtr io_
Image data IO pointer.
Definition: image.hpp:487
Exiv2::Image::iptcData
virtual IptcData & iptcData()
Returns an IptcData instance containing currently buffered IPTC data.
Definition: image.cpp:556
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:84
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
IPTC string type.
Definition: types.hpp:147
Exiv2::BasicIo::seek
virtual int seek(long offset, Position pos)=0
Move the current IO position.
Exiv2::ImageType::png
const int png
PNG image type (see class PngImage)
Definition: pngimage.hpp:51
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::ImageFactory::create
static Image::AutoPtr create(int type, const std::string &path)
Create an Image subclass of the requested type by creating a new image file. If the file already exis...
Definition: image.cpp:930
Exiv2::Image::xmpData_
XmpData xmpData_
XMP data container.
Definition: image.hpp:490
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::Image::exifData
virtual ExifData & exifData()
Returns an ExifData instance containing currently buffered Exif data.
Definition: image.cpp:551
error.hpp
Error class for exceptions, log message class.