Mercurial > geeqie
changeset 201:0ca12db715b7
improved support for older exiv2 versions
author | nadvornik |
---|---|
date | Mon, 24 Mar 2008 14:49:00 +0000 |
parents | 1a38eef1129a |
children | f95654aeec4b |
files | src/exiv2.cc |
diffstat | 1 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/exiv2.cc Mon Mar 24 14:03:46 2008 +0000 +++ b/src/exiv2.cc Mon Mar 24 14:49:00 2008 +0000 @@ -555,19 +555,20 @@ type = Exiv2::ImageFactory::getType(map_data, map_len); #if EXIV2_TEST_VERSION(0,16,0) - TiffHeaderBase *tiffHeader; + TiffHeaderBase *tiffHeader = NULL; #else - TiffHeade2 *tiffHeader; + TiffHeade2 *tiffHeader = NULL; #endif + Cr2Header *cr2Header = NULL; + switch (type) { case Exiv2::ImageType::tiff: tiffHeader = new TiffHeade2(); break; + case Exiv2::ImageType::cr2: + cr2Header = new Cr2Header(); + break; #if EXIV2_TEST_VERSION(0,16,0) - - case Exiv2::ImageType::cr2: - tiffHeader = new Cr2Header(); - break; case Exiv2::ImageType::orf: tiffHeader = new OrfHeader(); break; @@ -593,7 +594,6 @@ } // process tiff-like formats - if (!tiffHeader->read(map_data, map_len)) throw Error(3, "TIFF"); TiffCompFactoryFct createFct = TiffCreator::create; @@ -601,13 +601,23 @@ if (0 == rootDir.get()) { throw Error(1, "No root element defined in TIFF structure"); } + + if (tiffHeader) + { + if (!tiffHeader->read(map_data, map_len)) throw Error(3, "TIFF"); #if EXIV2_TEST_VERSION(0,16,0) - rootDir->setStart(map_data + tiffHeader->offset()); + rootDir->setStart(map_data + tiffHeader->offset()); #else - rootDir->setStart(map_data + tiffHeader->ifdOffset()); + rootDir->setStart(map_data + tiffHeader->ifdOffset()); #endif - TiffRwState::AutoPtr state( - new TiffRwState(tiffHeader->byteOrder(), 0, createFct)); + } + + if (cr2Header) + { + rootDir->setStart(map_data + cr2Header->offset()); + } + + TiffRwState::AutoPtr state(new TiffRwState(tiffHeader ? tiffHeader->byteOrder() : littleEndian, 0, createFct)); TiffReader reader(map_data, map_len, @@ -616,7 +626,10 @@ rootDir->accept(reader); - delete tiffHeader; + if (tiffHeader) + delete tiffHeader; + if (cr2Header) + delete cr2Header; } RawFile::~RawFile()