Exiv2
Loading...
Searching...
No Matches
jpgimage.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 */
33#ifndef JPGIMAGE_HPP_
34#define JPGIMAGE_HPP_
35
36// *****************************************************************************
37#include "exiv2lib_export.h"
38
39// included header files
40#include "image.hpp"
41
42// *****************************************************************************
43// namespace extensions
44namespace Exiv2 {
45
46// *****************************************************************************
47// class definitions
48
49 // Supported JPEG image formats
50 namespace ImageType {
51 const int jpeg = 1;
52 const int exv = 2;
53 }
54
59 struct EXIV2API Photoshop {
60 // Todo: Public for now
61 static const char ps3Id_[];
62 static const char* irbId_[];
63 static const char bimId_[];
64 static const uint16_t iptc_;
65 static const uint16_t preview_;
66
75 static bool isIrb(const byte* pPsData,
76 long sizePsData);
85 static bool valid(const byte* pPsData,
86 long sizePsData);
104 static int locateIrb(const byte *pPsData,
105 long sizePsData,
106 uint16_t psTag,
107 const byte **record,
108 uint32_t *const sizeHdr,
109 uint32_t *const sizeData);
113 static int locateIptcIrb(const byte *pPsData,
114 long sizePsData,
115 const byte **record,
116 uint32_t *const sizeHdr,
117 uint32_t *const sizeData);
121 static int locatePreviewIrb(const byte *pPsData,
122 long sizePsData,
123 const byte **record,
124 uint32_t *const sizeHdr,
125 uint32_t *const sizeData);
135 static DataBuf setIptcIrb(const byte* pPsData,
136 long sizePsData,
137 const IptcData& iptcData);
138
139 }; // class Photoshop
140
144 class EXIV2API JpegBase : public Image {
145 public:
147
148 void readMetadata();
149 void writeMetadata();
150
157 void printStructure(std::ostream& out, PrintStructureOption option,int depth);
159
160 protected:
162
163
181 JpegBase(int type,
183 bool create,
184 const byte initData[],
185 long dataSize);
187
189
190
209 virtual bool isThisType(BasicIo& iIo, bool advance) const =0;
211
213
214
220 virtual int writeHeader(BasicIo& oIo) const =0;
222
223 // Constant Data
224 static const byte dht_;
225 static const byte dqt_;
226 static const byte dri_;
227 static const byte sos_;
228 static const byte eoi_;
229 static const byte app0_;
230 static const byte app1_;
231 static const byte app2_;
232 static const byte app13_;
233 static const byte com_;
234 static const byte sof0_;
235 static const byte sof1_;
236 static const byte sof2_;
237 static const byte sof3_;
238 static const byte sof5_;
239 static const byte sof6_;
240 static const byte sof7_;
241 static const byte sof9_;
242 static const byte sof10_;
243 static const byte sof11_;
244 static const byte sof13_;
245 static const byte sof14_;
246 static const byte sof15_;
247 static const char exifId_[];
248 static const char jfifId_[];
249 static const char xmpId_[];
250 static const char iccId_[];
251
252 private:
254
255
256 JpegBase();
258 JpegBase(const JpegBase& rhs);
260 JpegBase& operator=(const JpegBase& rhs);
262
264
265
272 int initImage(const byte initData[], long dataSize);
280 void doWriteMetadata(BasicIo& oIo);
282
284
285
293 int advanceToMarker() const;
295
296 }; // class JpegBase
297
301 class EXIV2API JpegImage : public JpegBase {
302 friend EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
303 public:
305
306
321 JpegImage(BasicIo::AutoPtr io, bool create);
323
325 std::string mimeType() const;
327
328 protected:
330
331 bool isThisType(BasicIo& iIo, bool advance) const;
333
335
343 int writeHeader(BasicIo& oIo) const;
345
346 private:
347 // Constant data
348 static const byte soi_; // SOI marker
349 static const byte blank_[]; // Minimal Jpeg image
350
351 // NOT Implemented
353 JpegImage();
355 JpegImage(const JpegImage& rhs);
357 JpegImage& operator=(const JpegImage& rhs);
358
359 }; // class JpegImage
360
362 class EXIV2API ExvImage : public JpegBase {
363 friend EXIV2API bool isExvType(BasicIo& iIo, bool advance);
364 public:
366
367
382 ExvImage(BasicIo::AutoPtr io, bool create);
384
386 std::string mimeType() const;
388
389 protected:
391
392 bool isThisType(BasicIo& iIo, bool advance) const;
394
396 int writeHeader(BasicIo& oIo) const;
398
399 private:
400 // Constant data
401 static const char exiv2Id_[]; // EXV identifier
402 static const byte blank_[]; // Minimal exiv2 file
403
404 // NOT Implemented
406 ExvImage();
408 ExvImage(const ExvImage& rhs);
410 ExvImage& operator=(const ExvImage& rhs);
411
412 }; // class ExvImage
413
414// *****************************************************************************
415// template, inline and free functions
416
417 // These could be static private functions on Image subclasses but then
418 // ImageFactory needs to be made a friend.
424 EXIV2API Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create);
426 EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
432 EXIV2API Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create);
434 EXIV2API bool isExvType(BasicIo& iIo, bool advance);
435
436} // namespace Exiv2
437
438#endif // #ifndef JPGIMAGE_HPP_
An interface for simple binary IO.
Definition basicio.hpp:55
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition basicio.hpp:58
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:204
Helper class to access Exiv2 files.
Definition jpgimage.hpp:362
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:81
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition image.hpp:84
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:173
Abstract helper base class to access JPEG images.
Definition jpgimage.hpp:144
static const byte app0_
JPEG APP0 marker.
Definition jpgimage.hpp:229
virtual int writeHeader(BasicIo &oIo) const =0
Writes the image header (aka signature) to the BasicIo instance.
static const byte com_
JPEG Comment marker.
Definition jpgimage.hpp:233
static const byte sof2_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:236
static const byte dri_
JPEG DRI marker.
Definition jpgimage.hpp:226
static const byte sof14_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:245
static const byte sof7_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:240
static const byte sof9_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:241
static const byte sof13_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:244
static const byte sof6_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:239
static const byte sof15_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:246
static const byte app1_
JPEG APP1 marker.
Definition jpgimage.hpp:230
static const byte sof1_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:235
static const byte sof11_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:243
virtual bool isThisType(BasicIo &iIo, bool advance) const =0
Determine if the content of the BasicIo instance is of the type supported by this class.
static const byte dqt_
JPEG DQT marker.
Definition jpgimage.hpp:225
static const byte dht_
JPEG DHT marker.
Definition jpgimage.hpp:224
static const byte sof0_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:234
static const byte app2_
JPEG APP2 marker.
Definition jpgimage.hpp:231
static const byte sos_
JPEG SOS marker.
Definition jpgimage.hpp:227
static const byte sof3_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:237
static const byte sof10_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:242
static const byte sof5_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:238
static const byte eoi_
JPEG EOI marker.
Definition jpgimage.hpp:228
static const byte app13_
JPEG APP13 marker.
Definition jpgimage.hpp:232
Class to access JPEG images.
Definition jpgimage.hpp:301
const int exv
EXV image type (see class ExvImage)
Definition jpgimage.hpp:52
const int jpeg
JPEG image type (see class JpegImage)
Definition jpgimage.hpp:51
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition asfvideo.hpp:36
PrintStructureOption
Options for printStructure.
Definition image.hpp:67
EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition jpgimage.cpp:1414
EXIV2API Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create)
Create a new ExvImage instance and return an auto-pointer to it. Caller owns the returned object and ...
Definition jpgimage.cpp:1406
EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition jpgimage.cpp:1362
EXIV2API Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create)
Create a new JpegImage instance and return an auto-pointer to it. Caller owns the returned object and...
Definition jpgimage.cpp:1353
Helper class, has methods to deal with Photoshop "Information Resource Blocks" (IRBs).
Definition jpgimage.hpp:59
static const uint16_t iptc_
Photoshop IPTC marker
Definition jpgimage.hpp:64
static const uint16_t preview_
Photoshop preview marker
Definition jpgimage.hpp:65