Exiv2
jp2image.hpp
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  */
20 
21 /*
22  File: jp2image.cpp
23 */
24 
25 #ifndef JP2IMAGE_HPP_
26 #define JP2IMAGE_HPP_
27 
28 // *****************************************************************************
29 #include "exiv2lib_export.h"
30 
31 // included header files
32 #include "image.hpp"
33 
34 // *****************************************************************************
35 // namespace extensions
36 namespace Exiv2
37 {
38 
39 // *****************************************************************************
40 // class definitions
41 
42  // Add JPEG-2000 to the supported image formats
43  namespace ImageType
44  {
45  const int jp2 = 15;
46  }
47 
51  class EXIV2API Jp2Image : public Image {
52  public:
54 
55 
69  Jp2Image(BasicIo::AutoPtr io, bool create);
71 
73 
74  void readMetadata();
75  void writeMetadata();
76 
83  void printStructure(std::ostream& out, PrintStructureOption option,int depth);
84 
89  void setComment(const std::string& comment);
91 
93 
94  std::string mimeType() const;
96 
97  private:
99 
100  Jp2Image(const Jp2Image& rhs);
103  Jp2Image& operator=(const Jp2Image& rhs);
111  void doWriteMetadata(BasicIo& oIo);
112 
118  void encodeJp2Header(const DataBuf& oldData,DataBuf& newData);
120 
121  }; // class Jp2Image
122 
123 // *****************************************************************************
124 // template, inline and free functions
125 
126  // These could be static private functions on Image subclasses but then
127  // ImageFactory needs to be made a friend.
133  EXIV2API Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create);
134 
136  EXIV2API bool isJp2Type(BasicIo& iIo, bool advance);
137 
138 } // namespace Exiv2
139 
140 #endif // #ifndef JP2IMAGE_HPP_
image_int.hpp
Internal image helpers.
Exiv2::MemIo
Provides binary IO on blocks of memory by implementing the BasicIo interface. A copy-on-write impleme...
Definition: basicio.hpp:540
Exiv2::ExifData::clear
void clear()
Delete all Exifdatum instances resulting in an empty container. Note that this also removes thumbnail...
Definition: exif.cpp:587
Exiv2::ImageType::xmp
const int xmp
XMP sidecar files (see class XmpSidecar)
Definition: xmpsidecar.hpp:45
Exiv2::Image::xmpPacket_
std::string xmpPacket_
XMP packet.
Definition: image.hpp:493
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::Jp2Image::setComment
void setComment(const std::string &comment)
Todo: Not supported yet(?). Calling this function will throw an instance of Error(kerInvalidSettingFo...
Definition: jp2image.cpp:161
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::Jp2Image
Class to access JPEG-2000 images.
Definition: jp2image.hpp:51
Exiv2::Jp2Image::writeMetadata
void writeMetadata()
Write metadata back to the image.
Definition: jp2image.cpp:624
types.hpp
Type definitions for Exiv2 and related functionality.
Exiv2::IptcParser::decode
static int decode(IptcData &iptcData, const byte *pData, uint32_t size)
Decode binary IPTC data in IPTC IIM4 format from a buffer pData of length size to the provided metada...
Definition: iptc.cpp:432
Exiv2::makeSlice
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:673
Exiv2::comment
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:150
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::TiffParser::decode
static ByteOrder decode(ExifData &exifData, IptcData &iptcData, XmpData &xmpData, const byte *pData, uint32_t size)
Decode metadata from a buffer pData of length size with data in TIFF format to the provided metadata ...
Definition: tiffimage.cpp:251
Exiv2::Internal::binaryToString
binaryToStringHelper< T > binaryToString(const Slice< T > sl)
format binary data for display in Image::printStructure()
Definition: image_int.hpp:125
Exiv2::IptcData::clear
void clear()
Delete all Iptcdatum instances resulting in an empty container.
Definition: iptc.hpp:218
Exiv2::Image::iccProfileDefined
virtual bool iccProfileDefined()
Erase iccProfile. the profile is not removed from the actual image until the writeMetadata() method i...
Definition: image.hpp:238
Exiv2::Image::pixelHeight_
int pixelHeight_
image pixel height
Definition: image.hpp:495
Exiv2::Jp2Image::Jp2Image
Jp2Image(BasicIo::AutoPtr io, bool create)
Constructor to open a JPEG-2000 image. Since the constructor can not return a result,...
Definition: jp2image.cpp:135
enforce.hpp
Port of D's enforce() to C++ & Exiv2.
Exiv2::ImageType::jp2
const int jp2
JPEG-2000 image type.
Definition: jp2image.hpp:45
Exiv2::ExifParser::encode
static WriteMethod encode(Blob &blob, const byte *pData, uint32_t size, ByteOrder byteOrder, const ExifData &exifData)
Encode Exif metadata from the provided metadata to binary Exif format.
Definition: exif.cpp:644
Exiv2::Internal::stringFormat
std::string stringFormat(const char *format,...)
format a string in the pattern of sprintf .
Definition: image_int.cpp:32
Exiv2::Image::setByteOrder
void setByteOrder(ByteOrder byteOrder)
Set the byte order to encode the Exif metadata in.
Definition: image.cpp:678
Exiv2::Jp2Image::mimeType
std::string mimeType() const
Return the MIME type of the image.
Definition: jp2image.cpp:156
Exiv2::IptcData::printStructure
static void printStructure(std::ostream &out, const Slice< byte * > &bytes, uint32_t depth)
dump iptc formatted binary data (used by printStructure kpsRecursive)
Definition: iptc.cpp:351
Exiv2::getShort
EXIV2API int16_t getShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte signed short value from the data buffer.
Definition: types.cpp:318
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::printTiffStructure
void printTiffStructure(BasicIo &io, std::ostream &out, PrintStructureOption option, int depth, size_t offset=0)
Print out the structure of image file.
Definition: image.cpp:523
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::DataBuf::alloc
void alloc(long size)
Allocate a data buffer of at least the given size. Note that if the requested size is less than the c...
Definition: types.cpp:161
Exiv2::DataBuf::size_
long size_
The current size of the buffer.
Definition: types.hpp:271
Exiv2::getLong
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition: types.cpp:328
Exiv2::XmpParser::encode
static int encode(std::string &xmpPacket, const XmpData &xmpData, uint16_t formatFlags=useCompactFormat, uint32_t padding=0)
Encode (serialize) XMP metadata from xmpData into a string xmpPacket. The XMP packet returned in the ...
Definition: xmp.cpp:836
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::ExifData::count
long count() const
Get the number of metadata entries.
Definition: exif.hpp:514
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::ul2Data
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:408
safe_op.hpp
Overflow checks for integers.
EXV_WARNING
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
Exiv2::Image::io_
BasicIo::AutoPtr io_
Image data IO pointer.
Definition: image.hpp:487
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:113
Exiv2::Image::iccProfile_
DataBuf iccProfile_
ICC buffer (binary data)
Definition: image.hpp:491
Exiv2::Jp2Image::printStructure
void printStructure(std::ostream &out, PrintStructureOption option, int depth)
Print out the structure of image file.
Definition: jp2image.cpp:465
Exiv2::Image::AutoPtr
std::auto_ptr< Image > AutoPtr
Image auto_ptr type.
Definition: image.hpp:84
Safe::add
T add(T summand_1, T summand_2)
Safe addition, throws an exception on overflow.
Definition: safe_op.hpp:295
Exiv2::BasicIo::AutoPtr
std::auto_ptr< BasicIo > AutoPtr
BasicIo auto_ptr type.
Definition: basicio.hpp:58
Exiv2::Image::writeXmpFromPacket
bool writeXmpFromPacket() const
Return the flag indicating the source when writing XMP metadata.
Definition: image.cpp:728
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:323
Exiv2::IptcParser::encode
static DataBuf encode(const IptcData &iptcData)
Encode the IPTC datasets from iptcData to a binary representation in IPTC IIM4 format.
Definition: iptc.cpp:509
Exiv2::newJp2Instance
EXIV2API Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create)
Create a new Jp2Image instance and return an auto-pointer to it. Caller owns the returned object and ...
Definition: jp2image.cpp:960
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
Exiv2::PrintStructureOption
PrintStructureOption
Options for printStructure.
Definition: image.hpp:67
EXV_ERROR
#define EXV_ERROR
Shorthand for a temp error log message object and return its ostringstream.
Definition: error.hpp:150
Exiv2::BasicIo::seek
virtual int seek(long offset, Position pos)=0
Move the current IO position.
Exiv2::isJp2Type
EXIV2API bool isJp2Type(BasicIo &iIo, bool advance)
Check if the file iIo is a JPEG-2000 image.
Definition: jp2image.cpp:970
Exiv2::BasicIo
An interface for simple binary IO.
Definition: basicio.hpp:55
Exiv2::IptcData::count
long count() const
Get the number of metadata entries.
Definition: iptc.hpp:260
Exiv2::Image::xmpData_
XmpData xmpData_
XMP data container.
Definition: image.hpp:490
Exiv2::Image::xmpData
virtual XmpData & xmpData()
Returns an XmpData instance containing currently buffered XMP data.
Definition: image.cpp:561
Exiv2::Image
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:81
Exiv2::Image::setIccProfile
virtual void setIccProfile(DataBuf &iccProfile, bool bTestValid=true)
Set the image iccProfile. The new profile is not written to the image until the writeMetadata() metho...
Definition: image.cpp:663
futils.hpp
Basic file utility functions required by Exiv2.
Exiv2::Jp2Image::readMetadata
void readMetadata()
Read all metadata supported by a specific image format from the image. Before this method is called,...
Definition: jp2image.cpp:207
Exiv2::XmpParser::decode
static int decode(XmpData &xmpData, const std::string &xmpPacket)
Decode XMP metadata from an XMP packet xmpPacket into xmpData. The format of the XMP packet must foll...
Definition: xmp.cpp:723
Exiv2::Image::iptcData
virtual IptcData & iptcData()
Returns an IptcData instance containing currently buffered IPTC data.
Definition: image.cpp:556
Exiv2::getULong
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:283
error.hpp
Error class for exceptions, log message class.
Exiv2::Image::exifData
virtual ExifData & exifData()
Returns an ExifData instance containing currently buffered Exif data.
Definition: image.cpp:551
Exiv2::Blob
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:162