You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
20 years ago
|
// ***************************************************************** -*- C++ -*-
|
||
|
// crwparse.cpp, $Rev$
|
||
|
// Print the CIFF structure of a CRW file
|
||
|
|
||
18 years ago
|
#include <exiv2/crwimage.hpp>
|
||
|
#include <exiv2/futils.hpp>
|
||
20 years ago
|
|
||
|
#include <iostream>
|
||
|
|
||
|
int main(int argc, char* const argv[])
|
||
|
try {
|
||
|
if (argc != 2) {
|
||
|
std::cout << "Usage: " << argv[0] << " file\n";
|
||
|
std::cout << "Print the CIFF structure of a CRW file\n";
|
||
|
return 1;
|
||
|
}
|
||
20 years ago
|
|
||
20 years ago
|
Exiv2::FileIo io(argv[1]);
|
||
|
if(io.open() != 0) {
|
||
|
throw Exiv2::Error(9, io.path(), Exiv2::strError());
|
||
|
}
|
||
|
Exiv2::IoCloser closer(io);
|
||
|
|
||
|
// Ensure that this is a CRW image
|
||
|
if (!Exiv2::isCrwType(io, false)) {
|
||
|
if (io.error() || io.eof()) throw Exiv2::Error(14);
|
||
|
throw Exiv2::Error(33);
|
||
|
}
|
||
|
|
||
|
// Read the image into a memory buffer
|
||
|
long len = io.size();
|
||
|
Exiv2::DataBuf buf(len);
|
||
|
io.read(buf.pData_, len);
|
||
|
if (io.error() || io.eof()) throw Exiv2::Error(14);
|
||
|
|
||
|
// Parse the image, starting with a CIFF header component
|
||
|
Exiv2::CiffHeader::AutoPtr parseTree(new Exiv2::CiffHeader);
|
||
|
parseTree->read(buf.pData_, buf.size_);
|
||
|
parseTree->print(std::cout);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
catch (Exiv2::AnyError& e) {
|
||
|
std::cerr << e << "\n";
|
||
|
return -1;
|
||
|
}
|