1 | // ***************************************************************** -*- C++ -*- |
2 | /* |
3 | * Copyright (C) 2004-2013 Andreas Huggel <ahuggel@gmx.net> |
4 | * |
5 | * This program is part of the Exiv2 distribution. |
6 | * |
7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License |
9 | * as published by the Free Software Foundation; either version 2 |
10 | * of the License, or (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. |
20 | */ |
21 | /*! |
22 | @file pgfimage.hpp |
23 | @brief PGF image, implemented using the following references: |
24 | <a href="http://www.libpgf.org/uploads/media/PGF_stamm_wscg02.pdf">PGF specification</a> from libpgf web site<br> |
25 | @version $Rev: 3091 $ |
26 | @author Andreas Huggel (ahu) |
27 | <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> |
28 | @author Gilles Caulier (cgilles) |
29 | <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> |
30 | @date 16-Jun-09, gc: submitted |
31 | */ |
32 | #ifndef PGFIMAGE_HPP_ |
33 | #define PGFIMAGE_HPP_ |
34 | |
35 | // ***************************************************************************** |
36 | // included header files |
37 | #include "image.hpp" |
38 | #include "basicio.hpp" |
39 | #include "types.hpp" |
40 | |
41 | // + standard includes |
42 | #include <string> |
43 | |
44 | // ***************************************************************************** |
45 | // namespace extensions |
46 | namespace Exiv2 |
47 | { |
48 | |
49 | // ***************************************************************************** |
50 | // class definitions |
51 | |
52 | // Add PGF to the supported image formats |
53 | namespace ImageType |
54 | { |
55 | const int pgf = 17; //!< PGF image type (see class PgfImage) |
56 | } |
57 | |
58 | /*! |
59 | @brief Class to access PGF images. Exif and IPTC metadata are supported |
60 | directly. |
61 | */ |
62 | class EXIV2API PgfImage : public Image { |
63 | public: |
64 | //! @name Creators |
65 | //@{ |
66 | /*! |
67 | @brief Constructor that can either open an existing PGF image or create |
68 | a new image from scratch. If a new image is to be created, any |
69 | existing data is overwritten. Since the constructor can not return |
70 | a result, callers should check the good() method after object |
71 | construction to determine success or failure. |
72 | @param io An auto-pointer that owns a BasicIo instance used for |
73 | reading and writing image metadata. \b Important: The constructor |
74 | takes ownership of the passed in BasicIo instance through the |
75 | auto-pointer. Callers should not continue to use the BasicIo |
76 | instance after it is passed to this method. Use the Image::io() |
77 | method to get a temporary reference. |
78 | @param create Specifies if an existing image should be read (false) |
79 | or if a new file should be created (true). |
80 | */ |
81 | PgfImage(BasicIo::AutoPtr io, bool create); |
82 | //@} |
83 | |
84 | //! @name Manipulators |
85 | //@{ |
86 | void readMetadata(); |
87 | void writeMetadata(); |
88 | //@} |
89 | |
90 | //! @name Accessors |
91 | //@{ |
92 | std::string mimeType() const { return "image/pgf" ; } |
93 | //@} |
94 | |
95 | private: |
96 | //! @name NOT implemented |
97 | //@{ |
98 | //! Copy constructor |
99 | PgfImage(const PgfImage& rhs); |
100 | //! Assignment operator |
101 | PgfImage& operator=(const PgfImage& rhs); |
102 | /*! |
103 | @brief Provides the main implementation of writeMetadata() by |
104 | writing all buffered metadata to the provided BasicIo. |
105 | @param oIo BasicIo instance to write to (a temporary location). |
106 | |
107 | @return 4 if opening or writing to the associated BasicIo fails |
108 | */ |
109 | EXV_DLLLOCAL void doWriteMetadata(BasicIo& oIo); |
110 | //! Read Magick number. Only version >= 6 is supported. |
111 | byte readPgfMagicNumber(BasicIo& iIo); |
112 | //! Read PGF Header size encoded in 32 bits integer. |
113 | uint32_t (BasicIo& iIo); |
114 | //! Read header structure. |
115 | DataBuf (BasicIo& iIo, int* width, int* height); |
116 | //@} |
117 | |
118 | }; // class PgfImage |
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. |
125 | /*! |
126 | @brief Create a new PgfImage instance and return an auto-pointer to it. |
127 | Caller owns the returned object and the auto-pointer ensures that |
128 | it will be deleted. |
129 | */ |
130 | EXIV2API Image::AutoPtr newPgfInstance(BasicIo::AutoPtr io, bool create); |
131 | |
132 | //! Check if the file iIo is a PGF image. |
133 | EXIV2API bool isPgfType(BasicIo& iIo, bool advance); |
134 | |
135 | } // namespace Exiv2 |
136 | |
137 | #endif // #ifndef PGFIMAGE_HPP_ |
138 | |