MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / LoaderTiff

Method LoaderTiff

src/preview.cpp:612–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610}
611
612LoaderTiff::LoaderTiff(PreviewId id, const Image& image, int parIdx) :
613 Loader(id, image), group_(param_[parIdx].group_) {
614 const ExifData& exifData = image_.exifData();
615
616 size_t offsetCount = 0;
617 ExifData::const_iterator pos;
618
619 // check if the group_ contains a preview image
620 if (param_[parIdx].checkTag_) {
621 pos = exifData.findKey(ExifKey(param_[parIdx].checkTag_));
622 if (pos == exifData.end())
623 return;
624 if (param_[parIdx].checkValue_ && pos->toString() != param_[parIdx].checkValue_)
625 return;
626 }
627
628 pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".StripOffsets"));
629 if (pos != exifData.end()) {
630 offsetTag_ = "StripOffsets";
631 sizeTag_ = "StripByteCounts";
632 offsetCount = pos->value().count();
633 } else {
634 pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".TileOffsets"));
635 if (pos == exifData.end())
636 return;
637 offsetTag_ = "TileOffsets";
638 sizeTag_ = "TileByteCounts";
639 offsetCount = pos->value().count();
640 }
641
642 pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + '.' + sizeTag_));
643 if (pos == exifData.end())
644 return;
645 if (offsetCount != pos->value().count())
646 return;
647 for (size_t i = 0; i < offsetCount; i++) {
648 size_ += pos->toUint32(i);
649 }
650
651 if (size_ == 0)
652 return;
653
654 pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".ImageWidth"));
655 if (pos != exifData.end() && pos->count() > 0) {
656 width_ = pos->toUint32();
657 }
658
659 pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".ImageLength"));
660 if (pos != exifData.end() && pos->count() > 0) {
661 height_ = pos->toUint32();
662 }
663
664 if (width_ == 0 || height_ == 0)
665 return;
666
667 valid_ = true;
668}
669

Callers

nothing calls this directly

Calls 6

ExifKeyClass · 0.85
findKeyMethod · 0.45
endMethod · 0.45
toStringMethod · 0.45
countMethod · 0.45
toUint32Method · 0.45

Tested by

no test coverage detected