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 orfimage.hpp |
23 | @brief Olympus RAW image |
24 | @version $Rev: 3091 $ |
25 | @author Jeff Costlow |
26 | <a href="mailto:costlow@gmail.com">costlow@gmail.com</a> |
27 | @date 31-Jul-07, costlow: created |
28 | */ |
29 | #ifndef ORFIMAGE_HPP_ |
30 | #define ORFIMAGE_HPP_ |
31 | |
32 | // ***************************************************************************** |
33 | // included header files |
34 | #include "image.hpp" |
35 | #include "basicio.hpp" |
36 | #include "types.hpp" |
37 | |
38 | // + standard includes |
39 | #include <string> |
40 | |
41 | // ***************************************************************************** |
42 | // namespace extensions |
43 | namespace Exiv2 { |
44 | |
45 | // ***************************************************************************** |
46 | // class definitions |
47 | |
48 | // Add ORF to the supported image formats |
49 | namespace ImageType { |
50 | const int orf = 9; //!< ORF image type (see class OrfImage) |
51 | } |
52 | |
53 | /*! |
54 | @brief Class to access raw Olympus ORF images. Exif metadata is supported |
55 | directly, IPTC is read from the Exif data, if present. |
56 | */ |
57 | class EXIV2API OrfImage : public Image { |
58 | public: |
59 | //! @name Creators |
60 | //@{ |
61 | /*! |
62 | @brief Constructor that can either open an existing ORF image or create |
63 | a new image from scratch. If a new image is to be created, any |
64 | existing data is overwritten. Since the constructor can not return |
65 | a result, callers should check the good() method after object |
66 | construction to determine success or failure. |
67 | @param io An auto-pointer that owns a BasicIo instance used for |
68 | reading and writing image metadata. \b Important: The constructor |
69 | takes ownership of the passed in BasicIo instance through the |
70 | auto-pointer. Callers should not continue to use the BasicIo |
71 | instance after it is passed to this method. Use the Image::io() |
72 | method to get a temporary reference. |
73 | @param create Specifies if an existing image should be read (false) |
74 | or if a new file should be created (true). |
75 | */ |
76 | OrfImage(BasicIo::AutoPtr io, bool create); |
77 | //@} |
78 | |
79 | //! @name Manipulators |
80 | //@{ |
81 | void readMetadata(); |
82 | void writeMetadata(); |
83 | /*! |
84 | @brief Not supported. ORF format does not contain a comment. |
85 | Calling this function will throw an Error(32). |
86 | */ |
87 | void (const std::string& ); |
88 | //@} |
89 | |
90 | //! @name Accessors |
91 | //@{ |
92 | std::string mimeType() const; |
93 | int pixelWidth() const; |
94 | int pixelHeight() const; |
95 | //@} |
96 | |
97 | private: |
98 | //! @name NOT Implemented |
99 | //@{ |
100 | //! Copy constructor |
101 | OrfImage(const OrfImage& rhs); |
102 | //! Assignment operator |
103 | OrfImage& operator=(const OrfImage& rhs); |
104 | //@} |
105 | |
106 | }; // class OrfImage |
107 | |
108 | /*! |
109 | @brief Stateless parser class for data in ORF format. Images use this |
110 | class to decode and encode ORF data. |
111 | See class TiffParser for details. |
112 | */ |
113 | class EXIV2API OrfParser { |
114 | public: |
115 | /*! |
116 | @brief Decode metadata from a buffer \em pData of length \em size |
117 | with data in ORF format to the provided metadata containers. |
118 | See TiffParser::decode(). |
119 | */ |
120 | static ByteOrder decode( |
121 | ExifData& exifData, |
122 | IptcData& iptcData, |
123 | XmpData& xmpData, |
124 | const byte* pData, |
125 | uint32_t size |
126 | ); |
127 | /*! |
128 | @brief Encode metadata from the provided metadata to ORF format. |
129 | See TiffParser::encode(). |
130 | */ |
131 | static WriteMethod encode( |
132 | BasicIo& io, |
133 | const byte* pData, |
134 | uint32_t size, |
135 | ByteOrder byteOrder, |
136 | const ExifData& exifData, |
137 | const IptcData& iptcData, |
138 | const XmpData& xmpData |
139 | ); |
140 | }; // class OrfParser |
141 | |
142 | // ***************************************************************************** |
143 | // template, inline and free functions |
144 | |
145 | // These could be static private functions on Image subclasses but then |
146 | // ImageFactory needs to be made a friend. |
147 | /*! |
148 | @brief Create a new OrfImage instance and return an auto-pointer to it. |
149 | Caller owns the returned object and the auto-pointer ensures that |
150 | it will be deleted. |
151 | */ |
152 | EXIV2API Image::AutoPtr newOrfInstance(BasicIo::AutoPtr io, bool create); |
153 | |
154 | //! Check if the file iIo is an ORF image. |
155 | EXIV2API bool isOrfType(BasicIo& iIo, bool advance); |
156 | |
157 | } // namespace Exiv2 |
158 | |
159 | #endif // #ifndef ORFIMAGE_HPP_ |
160 | |