Added a parser layer to the Crw image handling code. No functional change.

v0.27.3
Andreas Huggel 20 years ago
parent 8ef1d8f854
commit bce4645165

@ -150,19 +150,12 @@ namespace Exiv2 {
clearMetadata(); clearMetadata();
// Read the image into a memory buffer // Read the image into a memory buffer
long imageSize = io_->size(); long len = io_->size();
DataBuf image(imageSize); DataBuf buf(len);
io_->read(image.pData_, imageSize); io_->read(buf.pData_, len);
if (io_->error() || io_->eof()) throw Error(14); if (io_->error() || io_->eof()) throw Error(14);
// Parse the image CrwParser::decode(this, buf.pData_, buf.size_);
RawMetadata::AutoPtr parseTree(new CiffHeader);
parseTree->read(image.pData_, image.size_, 0, invalidByteOrder);
#ifdef DEBUG
parseTree->print(std::cerr, invalidByteOrder);
#endif
parseTree->extract(*this, invalidByteOrder);
} // CrwImage::readMetadata } // CrwImage::readMetadata
void CrwImage::writeMetadata() void CrwImage::writeMetadata()
@ -175,6 +168,21 @@ namespace Exiv2 {
return isCrwType(iIo, advance); return isCrwType(iIo, advance);
} }
void CrwParser::decode(CrwImage* crwImage, const byte* buf, uint32_t len)
{
assert(crwImage != 0);
assert(buf != 0);
// Parse the image
RawMetadata::AutoPtr parseTree(new CiffHeader);
parseTree->read(buf, len, 0, invalidByteOrder);
#ifdef DEBUG
parseTree->print(std::cerr, invalidByteOrder);
#endif
parseTree->extract(*crwImage, invalidByteOrder);
} // CrwParser::decode
void CiffComponent::read(const byte* buf, void CiffComponent::read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,

@ -257,6 +257,28 @@ namespace Exiv2 {
}; // class RawMetadata }; // class RawMetadata
/*!
Stateless parser class for Canon Crw images (Ciff format).
*/
class CrwParser {
public:
/*!
@brief Decode metadata from a Canon Crw image in data buffer \em buf of length
\em len into \em crwImage.
This is the entry point to access image data in Ciff format. The parser uses
classes CiffHeader, CiffEntry, CiffDirectory.
@param crwImage %Exiv2 Crw image to hold the metadata read from the buffer.
@param buf Pointer to the data buffer. Must point to the data of a Crw
image; no checks are performed.
@param len Length of the data buffer.
*/
static void decode(CrwImage* crwImage, const byte* buf, uint32_t len);
//! Todo: implement me!
static void encode();
};
/*! /*!
@brief Interface class for components of the CIFF directory hierarchy of @brief Interface class for components of the CIFF directory hierarchy of
a Crw (Canon Raw data) image. Both CIFF directories as well as a Crw (Canon Raw data) image. Both CIFF directories as well as
@ -276,9 +298,6 @@ namespace Exiv2 {
//@{ //@{
// Default assignment operator is fine // Default assignment operator is fine
// See base class comment
virtual void add(RawMetadata::AutoPtr component) =0;
// See base class comment // See base class comment
virtual void read(const byte* buf, virtual void read(const byte* buf,
uint32_t len, uint32_t len,

Loading…
Cancel
Save