Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Examples

Exiv2::JpegBase Class Reference

Abstract helper base class to access JPEG images. More...

#include <image.hpp>

Inheritance diagram for Exiv2::JpegBase:

Inheritance graph
[legend]
Collaboration diagram for Exiv2::JpegBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Creators
virtual ~JpegBase ()
 Virtual destructor.
Manipulators
int readMetadata ()
 Read all metadata from the file into the internal data buffers. This method returns success even when no metadata is found in the image. Callers must therefore check the size of indivdual metadata types before accessing the data.
int writeMetadata ()
 Write all buffered metadata to associated file. All existing metadata sections in the file are either replaced or erased. If data for a given metadata type has not been assigned, then that metadata type will be erased from the file.
void setExifData (const byte *buf, long size)
 Set the Exif data. The data is copied into an internal data buffer and is not written until writeMetadata is called.
void clearExifData ()
 Erase any buffered Exif data. Exif data is not removed from the actual file until writeMetadata is called.
void setIptcData (const byte *buf, long size)
 Set the Iptc data. The data is copied into an internal data buffer and is not written until writeMetadata is called.
void clearIptcData ()
 Erase any buffered Iptc data. Iptc data is not removed from the actual file until writeMetadata is called.
void setComment (const std::string &comment)
 Set the image comment. The data is copied into an internal data buffer and is not written until writeMetadata is called.
void clearComment ()
 Erase any buffered comment. Comment is not removed from the actual file until writeMetadata is called.
void setMetadata (const Image &image)
 Copy all existing metadata from source Image. The data is copied into internal buffers and is not written until writeMetadata is called.
void clearMetadata ()
 Erase all buffered metadata. Metadata is not removed from the actual file until writeMetadata is called.
Accessors
bool good () const
 Check if the Image instance is valid. Use after object construction.
long sizeExifData () const
 Return the size of the Exif data in bytes.
const byteexifData () const
 Return a read-only pointer to an Exif data buffer. Do not attempt to write to this buffer.
long sizeIptcData () const
 Return the size of the Iptc data in bytes.
const byteiptcData () const
 Return a read-only pointer to an Iptc data buffer. Do not attempt to write to this buffer.
std::string comment () const
 Return a copy of the image comment. May be an empty string.

Protected Member Functions

Creators
 JpegBase (const std::string &path, bool create, const byte initData[], size_t 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 file is overwritten.
Accessors
virtual int writeHeader (FILE *ofp) const =0
 Writes the image header (aka signature) to the file stream.
virtual bool isThisType (FILE *ifp, bool advance) const =0
 Determine if the content of the stream is of the type of this class.

Static Protected Attributes

const byte sos_ = 0xda
 JPEG SOS marker.
const byte eoi_ = 0xd9
 JPEG EOI marker.
const byte app0_ = 0xe0
 JPEG APP0 marker.
const byte app1_ = 0xe1
 JPEG APP1 marker.
const byte app13_ = 0xed
 JPEG APP13 marker.
const byte com_ = 0xfe
 JPEG Comment marker.
const char exifId_ [] = "Exif\0\0"
 Exif identifier.
const char jfifId_ [] = "JFIF\0"
 JFIF identifier.
const char ps3Id_ [] = "Photoshop 3.0\0"
 Photoshop marker.
const char bimId_ [] = "8BIM"
 Photoshop marker.
const uint16_t iptc_ = 0x0404
 Photoshop Iptc marker.

Detailed Description

Abstract helper base class to access JPEG images.


Constructor & Destructor Documentation

Exiv2::JpegBase::JpegBase const std::string &  path,
bool  create,
const byte  initData[],
size_t  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 file is overwritten.

Parameters:
path Full path to image file.
create Specifies if an existing file should be opened (false) or if a new file should be created (true).
initData Data to initialize newly created files. Only used when create is true. Should contain the data for the smallest valid image of the calling subclass.
dataSize Size of initData in bytes.


Member Function Documentation

bool Exiv2::JpegBase::good  )  const [virtual]
 

Check if the Image instance is valid. Use after object construction.

Returns:
true if the Image is in a valid state.

Implements Exiv2::Image.

virtual bool Exiv2::JpegBase::isThisType FILE *  ifp,
bool  advance
const [protected, pure virtual]
 

Determine if the content of the stream is of the type of 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.

Parameters:
ifp Input file stream.
advance Flag indicating whether the read position in the stream should be advanced by the number of characters read to analyse the stream (true) or left at its original position (false). This applies only if the type matches.
Returns:
true if the stream data matches the type of this class;
false if the stream data does not match;

Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.

int Exiv2::JpegBase::readMetadata  )  [virtual]
 

Read all metadata from the file into the internal data buffers. This method returns success even when no metadata is found in the image. Callers must therefore check the size of indivdual metadata types before accessing the data.

Returns:
0 if successful;
1 if reading from the file failed (could be caused by invalid image);
2 if the file does not contain a valid image;

Implements Exiv2::Image.

void Exiv2::JpegBase::setComment const std::string &  comment  )  [virtual]
 

Set the image comment. The data is copied into an internal data buffer and is not written until writeMetadata is called.

Parameters:
comment String containing comment.

Implements Exiv2::Image.

void Exiv2::JpegBase::setExifData const byte buf,
long  size
[virtual]
 

Set the Exif data. The data is copied into an internal data buffer and is not written until writeMetadata is called.

Parameters:
buf Pointer to the new Exif data.
size Size in bytes of new Exif data.
Exceptions:
Error ("Exif data too large") if the exif data is larger than 65535 bytes (the maximum size of JPEG APP segments)

Implements Exiv2::Image.

void Exiv2::JpegBase::setIptcData const byte buf,
long  size
[virtual]
 

Set the Iptc data. The data is copied into an internal data buffer and is not written until writeMetadata is called.

Parameters:
buf Pointer to the new Iptc data.
size Size in bytes of new Iptc data.

Implements Exiv2::Image.

void Exiv2::JpegBase::setMetadata const Image image  )  [virtual]
 

Copy all existing metadata from source Image. The data is copied into internal buffers and is not written until writeMetadata is called.

Parameters:
image Metadata source. All metadata types are copied.

Implements Exiv2::Image.

virtual int Exiv2::JpegBase::writeHeader FILE *  ofp  )  const [protected, pure virtual]
 

Writes the image header (aka signature) to the file stream.

Parameters:
ofp File stream that the header is written to.
Returns:
0 if successful;
4 if the output file can not be written to;

Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.

int Exiv2::JpegBase::writeMetadata  )  [virtual]
 

Write all buffered metadata to associated file. All existing metadata sections in the file are either replaced or erased. If data for a given metadata type has not been assigned, then that metadata type will be erased from the file.

Returns:
0 if successful;
1 if reading from the file failed;
2 if the file does not contain a valid image;
4 if the temporary output file can not be written to;
-1 if the newly created file could not be reopened;
-3 if the temporary output file can not be opened;
-4 if renaming the temporary file fails;

Implements Exiv2::Image.


The documentation for this class was generated from the following files:
Generated on Sun Dec 12 17:54:06 2004 for Exiv2 by  doxygen 1.3.9.1