Mercurial > geeqie
comparison src/exiv2.cc @ 995:6ca2c5fd7b13
Whitespaces cleanup.
author | zas_ |
---|---|
date | Mon, 25 Aug 2008 22:20:45 +0000 |
parents | 0c3f6ef17d18 |
children | 68b0cb6ca8f0 |
comparison
equal
deleted
inserted
replaced
994:c879a4c14f33 | 995:6ca2c5fd7b13 |
---|---|
45 #include <exiv2/futils.hpp> | 45 #include <exiv2/futils.hpp> |
46 | 46 |
47 | 47 |
48 | 48 |
49 extern "C" { | 49 extern "C" { |
50 #include <glib.h> | 50 #include <glib.h> |
51 | 51 |
52 #include "main.h" | 52 #include "main.h" |
53 #include "exif.h" | 53 #include "exif.h" |
54 | 54 |
55 #include "filefilter.h" | 55 #include "filefilter.h" |
105 unsigned char *mapped = (unsigned char*)io.mmap(); | 105 unsigned char *mapped = (unsigned char*)io.mmap(); |
106 if (mapped) exif_jpeg_parse_color(this, mapped, io.size()); | 106 if (mapped) exif_jpeg_parse_color(this, mapped, io.size()); |
107 io.munmap(); | 107 io.munmap(); |
108 if (!open) io.close(); | 108 if (!open) io.close(); |
109 } | 109 } |
110 #endif | 110 #endif |
111 } | 111 } |
112 | 112 |
113 ~_ExifData() | 113 ~_ExifData() |
114 { | 114 { |
115 if (cp_data) g_free(cp_data); | 115 if (cp_data) g_free(cp_data); |
253 exif->exifIter = exif->exifData().begin(); | 253 exif->exifIter = exif->exifData().begin(); |
254 exif->iptcIter = exif->iptcData().begin(); | 254 exif->iptcIter = exif->iptcData().begin(); |
255 #if EXIV2_TEST_VERSION(0,16,0) | 255 #if EXIV2_TEST_VERSION(0,16,0) |
256 exif->xmpIter = exif->xmpData().begin(); | 256 exif->xmpIter = exif->xmpData().begin(); |
257 #endif | 257 #endif |
258 if (exif->exifIter != exif->exifData().end()) | 258 if (exif->exifIter != exif->exifData().end()) |
259 { | 259 { |
260 const Exiv2::Metadatum *item = &*exif->exifIter; | 260 const Exiv2::Metadatum *item = &*exif->exifIter; |
261 exif->exifIter++; | 261 exif->exifIter++; |
262 return (ExifItem *)item; | 262 return (ExifItem *)item; |
263 } | 263 } |
264 if (exif->iptcIter != exif->iptcData().end()) | 264 if (exif->iptcIter != exif->iptcData().end()) |
265 { | 265 { |
266 const Exiv2::Metadatum *item = &*exif->iptcIter; | 266 const Exiv2::Metadatum *item = &*exif->iptcIter; |
267 exif->iptcIter++; | 267 exif->iptcIter++; |
268 return (ExifItem *)item; | 268 return (ExifItem *)item; |
269 } | 269 } |
270 #if EXIV2_TEST_VERSION(0,16,0) | 270 #if EXIV2_TEST_VERSION(0,16,0) |
271 if (exif->xmpIter != exif->xmpData().end()) | 271 if (exif->xmpIter != exif->xmpData().end()) |
272 { | 272 { |
273 const Exiv2::Metadatum *item = &*exif->xmpIter; | 273 const Exiv2::Metadatum *item = &*exif->xmpIter; |
274 exif->xmpIter++; | 274 exif->xmpIter++; |
275 return (ExifItem *)item; | 275 return (ExifItem *)item; |
276 } | 276 } |
384 invalidTypeId, unsignedByte, asciiString, unsignedShort, | 384 invalidTypeId, unsignedByte, asciiString, unsignedShort, |
385 unsignedLong, unsignedRational, signedByte, undefined, | 385 unsignedLong, unsignedRational, signedByte, undefined, |
386 signedShort, signedLong, signedRational, string, | 386 signedShort, signedLong, signedRational, string, |
387 date, time, comment, directory, | 387 date, time, comment, directory, |
388 xmpText, xmpAlt, xmpBag, xmpSeq, | 388 xmpText, xmpAlt, xmpBag, xmpSeq, |
389 langAlt, lastTypeId | 389 langAlt, lastTypeId |
390 */ | 390 */ |
391 | 391 |
392 static guint format_id_trans_tbl [] = { | 392 static guint format_id_trans_tbl [] = { |
393 EXIF_FORMAT_UNKNOWN, | 393 EXIF_FORMAT_UNKNOWN, |
394 EXIF_FORMAT_BYTE_UNSIGNED, | 394 EXIF_FORMAT_BYTE_UNSIGNED, |
480 std::string str = em->toString(idx); | 480 std::string str = em->toString(idx); |
481 #else | 481 #else |
482 std::string str = em->toString(); // FIXME | 482 std::string str = em->toString(); // FIXME |
483 #endif | 483 #endif |
484 if (idx == 0 && str == "") str = em->toString(); | 484 if (idx == 0 && str == "") str = em->toString(); |
485 if (str.length() > 5 && str.substr(0, 5) == "lang=") | 485 if (str.length() > 5 && str.substr(0, 5) == "lang=") |
486 { | 486 { |
487 std::string::size_type pos = str.find_first_of(' '); | 487 std::string::size_type pos = str.find_first_of(' '); |
488 if (pos != std::string::npos) str = str.substr(pos+1); | 488 if (pos != std::string::npos) str = str.substr(pos+1); |
489 } | 489 } |
490 | 490 |
491 return g_strdup(str.c_str()); | 491 return g_strdup(str.c_str()); |
492 } | 492 } |
493 catch (Exiv2::AnyError& e) { | 493 catch (Exiv2::AnyError& e) { |
571 if (((Exiv2::Metadatum *)item) == &*i) { | 571 if (((Exiv2::Metadatum *)item) == &*i) { |
572 i = exif->xmpData().erase(i); | 572 i = exif->xmpData().erase(i); |
573 return 1; | 573 return 1; |
574 } | 574 } |
575 } | 575 } |
576 #endif | 576 #endif |
577 return 0; | 577 return 0; |
578 } | 578 } |
579 catch (Exiv2::AnyError& e) { | 579 catch (Exiv2::AnyError& e) { |
580 return 0; | 580 return 0; |
581 } | 581 } |
603 | 603 |
604 | 604 |
605 | 605 |
606 } | 606 } |
607 | 607 |
608 /* This is a dirty hack to support raw file preview, bassed on | 608 /* This is a dirty hack to support raw file preview, bassed on |
609 tiffparse.cpp from Exiv2 examples */ | 609 tiffparse.cpp from Exiv2 examples */ |
610 | 610 |
611 class RawFile { | 611 class RawFile { |
612 public: | 612 public: |
613 | 613 |
614 RawFile(int fd); | 614 RawFile(int fd); |
615 ~RawFile(); | 615 ~RawFile(); |
616 | 616 |
617 const Exiv2::Value *find(uint16_t tag, uint16_t group); | 617 const Exiv2::Value *find(uint16_t tag, uint16_t group); |
618 | 618 |
619 unsigned long preview_offset(); | 619 unsigned long preview_offset(); |
620 | 620 |
621 private: | 621 private: |
622 int type; | 622 int type; |
623 Exiv2::TiffComponent::AutoPtr rootDir; | 623 Exiv2::TiffComponent::AutoPtr rootDir; |
624 Exiv2::byte *map_data; | 624 Exiv2::byte *map_data; |
625 size_t map_len; | 625 size_t map_len; |
662 tiffHeader = new OrfHeader(); | 662 tiffHeader = new OrfHeader(); |
663 break; | 663 break; |
664 #endif | 664 #endif |
665 #if EXIV2_TEST_VERSION(0,13,0) | 665 #if EXIV2_TEST_VERSION(0,13,0) |
666 case Exiv2::ImageType::raf: | 666 case Exiv2::ImageType::raf: |
667 if (map_len < 84 + 4) throw Error(14); | 667 if (map_len < 84 + 4) throw Error(14); |
668 offset = getULong(map_data + 84, bigEndian); | 668 offset = getULong(map_data + 84, bigEndian); |
669 return; | 669 return; |
670 #endif | 670 #endif |
671 case Exiv2::ImageType::crw: | 671 case Exiv2::ImageType::crw: |
672 { | 672 { |
673 // Parse the image, starting with a CIFF header component | 673 // Parse the image, starting with a CIFF header component |
674 Exiv2::CiffHeader::AutoPtr parseTree(new Exiv2::CiffHeader); | 674 Exiv2::CiffHeader::AutoPtr parseTree(new Exiv2::CiffHeader); |
675 parseTree->read(map_data, map_len); | 675 parseTree->read(map_data, map_len); |
676 CiffComponent *entry = parseTree->findComponent(0x2007, 0); | 676 CiffComponent *entry = parseTree->findComponent(0x2007, 0); |
677 if (entry) offset = entry->pData() - map_data; | 677 if (entry) offset = entry->pData() - map_data; |
678 return; | 678 return; |
679 } | 679 } |
680 | 680 |
681 default: | 681 default: |
686 | 686 |
687 TiffCompFactoryFct createFct = TiffCreator::create; | 687 TiffCompFactoryFct createFct = TiffCreator::create; |
688 | 688 |
689 rootDir = createFct(Tag::root, Group::none); | 689 rootDir = createFct(Tag::root, Group::none); |
690 if (0 == rootDir.get()) { | 690 if (0 == rootDir.get()) { |
691 throw Error(1, "No root element defined in TIFF structure"); | 691 throw Error(1, "No root element defined in TIFF structure"); |
692 } | 692 } |
693 | 693 |
694 if (tiffHeader) | 694 if (tiffHeader) |
695 { | 695 { |
696 if (!tiffHeader->read(map_data, map_len)) throw Error(3, "TIFF"); | 696 if (!tiffHeader->read(map_data, map_len)) throw Error(3, "TIFF"); |
707 } | 707 } |
708 | 708 |
709 TiffRwState::AutoPtr state(new TiffRwState(tiffHeader ? tiffHeader->byteOrder() : littleEndian, 0, createFct)); | 709 TiffRwState::AutoPtr state(new TiffRwState(tiffHeader ? tiffHeader->byteOrder() : littleEndian, 0, createFct)); |
710 | 710 |
711 TiffReader reader(map_data, | 711 TiffReader reader(map_data, |
712 map_len, | 712 map_len, |
713 rootDir.get(), | 713 rootDir.get(), |
714 state); | 714 state); |
715 | 715 |
716 rootDir->accept(reader); | 716 rootDir->accept(reader); |
717 | 717 |
718 if (tiffHeader) | 718 if (tiffHeader) |
719 delete tiffHeader; | 719 delete tiffHeader; |
720 if (cr2Header) | 720 if (cr2Header) |
721 delete cr2Header; | 721 delete cr2Header; |
722 } | 722 } |
723 | 723 |
724 RawFile::~RawFile(void) | 724 RawFile::~RawFile(void) |
725 { | 725 { |
750 | 750 |
751 if (type == Exiv2::ImageType::cr2) | 751 if (type == Exiv2::ImageType::cr2) |
752 { | 752 { |
753 val = find(0x111, Group::ifd0); | 753 val = find(0x111, Group::ifd0); |
754 if (val) return val->toLong(); | 754 if (val) return val->toLong(); |
755 | 755 |
756 return 0; | 756 return 0; |
757 } | 757 } |
758 | 758 |
759 val = find(0x201, Group::sub0_0); | 759 val = find(0x201, Group::sub0_0); |
760 if (val) return val->toLong(); | 760 if (val) return val->toLong(); |
761 | 761 |
762 val = find(0x201, Group::ifd0); | 762 val = find(0x201, Group::ifd0); |
763 if (val) return val->toLong(); | 763 if (val) return val->toLong(); |
764 | 764 |
765 val = find(0x201, Group::ignr); // for PEF files, originally it was probably ifd2 | 765 val = find(0x201, Group::ignr); // for PEF files, originally it was probably ifd2 |
766 if (val) return val->toLong(); | 766 if (val) return val->toLong(); |
767 | 767 |
768 val = find(0x111, Group::sub0_1); // dng | 768 val = find(0x111, Group::sub0_1); // dng |
769 if (val) return val->toLong(); | 769 if (val) return val->toLong(); |
807 | 807 |
808 return offset > 0; | 808 return offset > 0; |
809 } | 809 } |
810 | 810 |
811 | 811 |
812 #endif | 812 #endif |
813 /* HAVE_EXIV2 */ | 813 /* HAVE_EXIV2 */ |