Loading...
Searching...
No Matches
jpgimage.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef JPGIMAGE_HPP_
#define JPGIMAGE_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "image.hpp"
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class definitions
// Supported JPEG image formats
namespace ImageType {
const int jpeg = 1;
const int exv = 2;
}
struct EXIV2API Photoshop {
// Todo: Public for now
static const char ps3Id_[];
static const char* irbId_[];
static const char bimId_[];
static const uint16_t iptc_;
static const uint16_t preview_;
static bool isIrb(const byte* pPsData,
long sizePsData);
static bool valid(const byte* pPsData,
long sizePsData);
static int locateIrb(const byte *pPsData,
long sizePsData,
uint16_t psTag,
const byte **record,
uint32_t *const sizeHdr,
uint32_t *const sizeData);
static int locateIptcIrb(const byte *pPsData,
long sizePsData,
const byte **record,
uint32_t *const sizeHdr,
uint32_t *const sizeData);
static int locatePreviewIrb(const byte *pPsData,
long sizePsData,
const byte **record,
uint32_t *const sizeHdr,
uint32_t *const sizeData);
static DataBuf setIptcIrb(const byte* pPsData,
long sizePsData,
const IptcData& iptcData);
}; // class Photoshop
class EXIV2API JpegBase : public Image {
public:
void readMetadata();
void writeMetadata();
void printStructure(std::ostream& out, PrintStructureOption option,int depth);
protected:
JpegBase(int type,
BasicIo::AutoPtr io,
bool create,
const byte initData[],
long dataSize);
virtual bool isThisType(BasicIo& iIo, bool advance) const =0;
virtual int writeHeader(BasicIo& oIo) const =0;
// Constant Data
static const byte dht_;
static const byte dqt_;
static const byte dri_;
static const byte sos_;
static const byte eoi_;
static const byte app0_;
static const byte app1_;
static const byte app2_;
static const byte app13_;
static const byte com_;
static const byte sof0_;
static const byte sof1_;
static const byte sof2_;
static const byte sof3_;
static const byte sof5_;
static const byte sof6_;
static const byte sof7_;
static const byte sof9_;
static const byte sof10_;
static const byte sof11_;
static const byte sof13_;
static const byte sof14_;
static const byte sof15_;
static const char exifId_[];
static const char jfifId_[];
static const char xmpId_[];
static const char iccId_[];
private:
JpegBase();
JpegBase(const JpegBase& rhs);
JpegBase& operator=(const JpegBase& rhs);
int initImage(const byte initData[], long dataSize);
void doWriteMetadata(BasicIo& oIo);
int advanceToMarker() const;
}; // class JpegBase
class EXIV2API JpegImage : public JpegBase {
friend EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
public:
JpegImage(BasicIo::AutoPtr io, bool create);
std::string mimeType() const;
protected:
bool isThisType(BasicIo& iIo, bool advance) const;
int writeHeader(BasicIo& oIo) const;
private:
// Constant data
static const byte soi_; // SOI marker
static const byte blank_[]; // Minimal Jpeg image
// NOT Implemented
JpegImage();
JpegImage(const JpegImage& rhs);
JpegImage& operator=(const JpegImage& rhs);
}; // class JpegImage
class EXIV2API ExvImage : public JpegBase {
friend EXIV2API bool isExvType(BasicIo& iIo, bool advance);
public:
ExvImage(BasicIo::AutoPtr io, bool create);
std::string mimeType() const;
protected:
bool isThisType(BasicIo& iIo, bool advance) const;
int writeHeader(BasicIo& oIo) const;
private:
// Constant data
static const char exiv2Id_[]; // EXV identifier
static const byte blank_[]; // Minimal exiv2 file
// NOT Implemented
ExvImage();
ExvImage(const ExvImage& rhs);
ExvImage& operator=(const ExvImage& rhs);
}; // class ExvImage
// *****************************************************************************
// template, inline and free functions
// These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend.
EXIV2API Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create);
EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
EXIV2API Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create);
EXIV2API bool isExvType(BasicIo& iIo, bool advance);
} // namespace Exiv2
#endif // #ifndef JPGIMAGE_HPP_
Exiv2::BasicIo
An interface for simple binary IO.
Definition basicio.hpp:55
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition basicio.hpp:58
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:193
Exiv2::ExvImage
Helper class to access Exiv2 files.
Definition jpgimage.hpp:350
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:78
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition image.hpp:81
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:170
Exiv2::JpegBase
Abstract helper base class to access JPEG images.
Definition jpgimage.hpp:132
Exiv2::JpegBase::app0_
static const byte app0_
JPEG APP0 marker.
Definition jpgimage.hpp:217
Exiv2::JpegBase::writeHeader
virtual int writeHeader(BasicIo &oIo) const =0
Writes the image header (aka signature) to the BasicIo instance.
Exiv2::JpegBase::com_
static const byte com_
JPEG Comment marker.
Definition jpgimage.hpp:221
Exiv2::JpegBase::sof2_
static const byte sof2_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:224
Exiv2::JpegBase::dri_
static const byte dri_
JPEG DRI marker.
Definition jpgimage.hpp:214
Exiv2::JpegBase::sof14_
static const byte sof14_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:233
Exiv2::JpegBase::sof7_
static const byte sof7_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:228
Exiv2::JpegBase::sof9_
static const byte sof9_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:229
Exiv2::JpegBase::sof13_
static const byte sof13_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:232
Exiv2::JpegBase::sof6_
static const byte sof6_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:227
Exiv2::JpegBase::sof15_
static const byte sof15_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:234
Exiv2::JpegBase::app1_
static const byte app1_
JPEG APP1 marker.
Definition jpgimage.hpp:218
Exiv2::JpegBase::sof1_
static const byte sof1_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:223
Exiv2::JpegBase::sof11_
static const byte sof11_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:231
Exiv2::JpegBase::isThisType
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.
Exiv2::JpegBase::dqt_
static const byte dqt_
JPEG DQT marker.
Definition jpgimage.hpp:213
Exiv2::JpegBase::dht_
static const byte dht_
JPEG DHT marker.
Definition jpgimage.hpp:212
Exiv2::JpegBase::sof0_
static const byte sof0_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:222
Exiv2::JpegBase::app2_
static const byte app2_
JPEG APP2 marker.
Definition jpgimage.hpp:219
Exiv2::JpegBase::sos_
static const byte sos_
JPEG SOS marker.
Definition jpgimage.hpp:215
Exiv2::JpegBase::sof3_
static const byte sof3_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:225
Exiv2::JpegBase::sof10_
static const byte sof10_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:230
Exiv2::JpegBase::sof5_
static const byte sof5_
JPEG Start-Of-Frame marker.
Definition jpgimage.hpp:226
Exiv2::JpegBase::eoi_
static const byte eoi_
JPEG EOI marker.
Definition jpgimage.hpp:216
Exiv2::JpegBase::app13_
static const byte app13_
JPEG APP13 marker.
Definition jpgimage.hpp:220
Exiv2::JpegImage
Class to access JPEG images.
Definition jpgimage.hpp:289
Exiv2::ImageType::exv
const int exv
EXV image type (see class ExvImage)
Definition jpgimage.hpp:40
Exiv2::ImageType::jpeg
const int jpeg
JPEG image type (see class JpegImage)
Definition jpgimage.hpp:39
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition asfvideo.hpp:36
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition image.hpp:64
Exiv2::isExvType
EXIV2API bool isExvType(BasicIo &iIo, bool advance)
Check if the file iIo is an EXV file.
Definition jpgimage.cpp:1410
Exiv2::newExvInstance
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:1402
Exiv2::isJpegType
EXIV2API bool isJpegType(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG image.
Definition jpgimage.cpp:1358
Exiv2::newJpegInstance
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:1349
Exiv2::Photoshop
Helper class, has methods to deal with Photoshop "Information Resource Blocks" (IRBs).
Definition jpgimage.hpp:47
Exiv2::Photoshop::iptc_
static const uint16_t iptc_
Photoshop IPTC marker
Definition jpgimage.hpp:52
Exiv2::Photoshop::preview_
static const uint16_t preview_
Photoshop preview marker
Definition jpgimage.hpp:53