Exiv2
|
Abstract helper base class to access JPEG images. More...
#include <jpgimage.hpp>
Protected Member Functions | |
Creators | |
JpegBase (int type, BasicIo::AutoPtr io, bool create, const byte initData[], long dataSize) | |
Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten. | |
Static Protected Attributes | |
static const byte | sos_ = 0xda |
JPEG SOS marker. | |
static const byte | eoi_ = 0xd9 |
JPEG EOI marker. | |
static const byte | app0_ = 0xe0 |
JPEG APP0 marker. | |
static const byte | app1_ = 0xe1 |
JPEG APP1 marker. | |
static const byte | app13_ = 0xed |
JPEG APP13 marker. | |
static const byte | com_ = 0xfe |
JPEG Comment marker. | |
static const byte | sof0_ = 0xc0 |
JPEG Start-Of-Frame marker. | |
static const byte | sof1_ = 0xc1 |
JPEG Start-Of-Frame marker. | |
static const byte | sof2_ = 0xc2 |
JPEG Start-Of-Frame marker. | |
static const byte | sof3_ = 0xc3 |
JPEG Start-Of-Frame marker. | |
static const byte | sof5_ = 0xc5 |
JPEG Start-Of-Frame marker. | |
static const byte | sof6_ = 0xc6 |
JPEG Start-Of-Frame marker. | |
static const byte | sof7_ = 0xc7 |
JPEG Start-Of-Frame marker. | |
static const byte | sof9_ = 0xc9 |
JPEG Start-Of-Frame marker. | |
static const byte | sof10_ = 0xca |
JPEG Start-Of-Frame marker. | |
static const byte | sof11_ = 0xcb |
JPEG Start-Of-Frame marker. | |
static const byte | sof13_ = 0xcd |
JPEG Start-Of-Frame marker. | |
static const byte | sof14_ = 0xce |
JPEG Start-Of-Frame marker. | |
static const byte | sof15_ = 0xcf |
JPEG Start-Of-Frame marker. | |
static const char | exifId_ [] = "Exif\0\0" |
Exif identifier. | |
static const char | jfifId_ [] = "JFIF\0" |
JFIF identifier. | |
static const char | xmpId_ [] = "http://ns.adobe.com/xap/1.0/\0" |
XMP packet identifier. | |
Manipulators | |
void | readMetadata () |
Read all metadata supported by a specific image format from the image. Before this method is called, the image metadata will be cleared. | |
void | writeMetadata () |
Write metadata back to the image. | |
virtual int | writeHeader (BasicIo &oIo) const =0 |
Writes the image header (aka signature) to the BasicIo instance. | |
Accessors | |
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. |
Abstract helper base class to access JPEG images.
Exiv2::JpegBase::JpegBase | ( | int | type, |
BasicIo::AutoPtr | io, | ||
bool | create, | ||
const byte | initData[], | ||
long | dataSize | ||
) | [protected] |
Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten.
type | Image type. |
io | An auto-pointer that owns a BasicIo instance used for reading and writing image metadata. Important: The constructor takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference. |
create | Specifies if an existing image should be read (false) or if a new image should be created (true). |
initData | Data to initialize newly created images. Only used when create is true. Should contain data for the smallest valid image of the calling subclass. |
dataSize | Size of initData in bytes. |
virtual bool Exiv2::JpegBase::isThisType | ( | BasicIo & | iIo, |
bool | advance | ||
) | const [protected, pure virtual] |
Determine if the content of the BasicIo instance is of the type supported by this class.
The advance flag determines if the read position in the stream is moved (see below). This applies only if the type matches and the function returns true. If the type does not match, the stream position is not changed. However, if reading from the stream fails, the stream position is undefined. Consult the stream state to obtain more information in this case.
iIo | BasicIo instance to read from. |
advance | Flag indicating whether the position of the io should be advanced by the number of characters read to analyse the data (true) or left at its original position (false). This applies only if the type matches. |
Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.
Referenced by readMetadata().
void Exiv2::JpegBase::readMetadata | ( | ) | [virtual] |
Read all metadata supported by a specific image format from the image. Before this method is called, the image metadata will be cleared.
This method returns success even if no metadata is found in the image. Callers must therefore check the size of individual metadata types before accessing the data.
Error | if opening or reading of the file fails or the image data is not valid (does not look like data of the specific image type). |
Implements Exiv2::Image.
References app13_, app1_, Exiv2::append(), Exiv2::Image::byteOrder(), Exiv2::IptcData::clear(), Exiv2::ExifData::clear(), Exiv2::Image::clearMetadata(), com_, Exiv2::Image::comment(), Exiv2::Image::comment_, Exiv2::IptcParser::decode(), Exiv2::XmpParser::decode(), Exiv2::ExifParser::decode(), eoi_, Exiv2::Image::exifData_, exifId_, Exiv2::getUShort(), Exiv2::Image::io_, Exiv2::Image::iptcData_, isThisType(), Exiv2::Photoshop::locateIptcIrb(), Exiv2::DataBuf::pData_, Exiv2::Image::pixelHeight_, Exiv2::Image::pixelWidth_, Exiv2::Photoshop::ps3Id_, Exiv2::Image::setByteOrder(), Exiv2::DataBuf::size_, sof0_, sof10_, sof11_, sof13_, sof14_, sof15_, sof1_, sof2_, sof3_, sof5_, sof6_, sof7_, sof9_, sos_, Exiv2::strError(), Exiv2::Photoshop::valid(), Exiv2::Image::xmpData_, xmpId_, Exiv2::Image::xmpPacket(), and Exiv2::Image::xmpPacket_.
virtual int Exiv2::JpegBase::writeHeader | ( | BasicIo & | oIo | ) | const [protected, pure virtual] |
Writes the image header (aka signature) to the BasicIo instance.
oIo | BasicIo instance that the header is written to. |
Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.
void Exiv2::JpegBase::writeMetadata | ( | ) | [virtual] |
Write metadata back to the image.
All existing metadata sections in the image are either created, replaced, or erased. If values for a given metadata type have been assigned, a section for that metadata type will either be created or replaced. If no values have been assigned to a given metadata type, any exists section for that metadata type will be removed from the image.
Error | if the operation fails |
Implements Exiv2::Image.
References Exiv2::Image::io_, and Exiv2::strError().