346 |
346 |
{
|
347 |
347 |
offset_ = 0;
|
348 |
348 |
ExifData::const_iterator pos = image_.exifData().findKey(ExifKey(param_[parIdx].offsetKey_));
|
349 |
|
if (pos != image_.exifData().end()) {
|
|
349 |
if (pos != image_.exifData().end() && pos->count() > 0) {
|
350 |
350 |
offset_ = pos->toLong();
|
351 |
351 |
}
|
352 |
352 |
|
353 |
353 |
size_ = 0;
|
354 |
354 |
pos = image_.exifData().findKey(ExifKey(param_[parIdx].sizeKey_));
|
355 |
|
if (pos != image_.exifData().end()) {
|
|
355 |
if (pos != image_.exifData().end() && pos->count() > 0) {
|
356 |
356 |
size_ = pos->toLong();
|
357 |
357 |
}
|
358 |
358 |
|
... | ... | |
360 |
360 |
|
361 |
361 |
if (param_[parIdx].baseOffsetKey_) {
|
362 |
362 |
pos = image_.exifData().findKey(ExifKey(param_[parIdx].baseOffsetKey_));
|
363 |
|
if (pos != image_.exifData().end()) {
|
|
363 |
if (pos != image_.exifData().end() && pos->count() > 0) {
|
364 |
364 |
offset_ += pos->toLong();
|
365 |
365 |
}
|
366 |
366 |
}
|
... | ... | |
540 |
540 |
if (pos == exifData.end()) return;
|
541 |
541 |
if (offsetCount != pos->value().count()) return;
|
542 |
542 |
for (int i = 0; i < offsetCount; i++) {
|
543 |
|
size_ += pos->value().toLong(i);
|
|
543 |
size_ += pos->toLong(i);
|
544 |
544 |
}
|
545 |
545 |
|
546 |
546 |
if (size_ == 0) return;
|
547 |
547 |
|
548 |
548 |
pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".ImageWidth"));
|
549 |
|
if (pos != exifData.end()) {
|
550 |
|
width_ = pos->value().toLong();
|
|
549 |
if (pos != exifData.end() && pos->count() > 0) {
|
|
550 |
width_ = pos->toLong();
|
551 |
551 |
}
|
552 |
552 |
|
553 |
553 |
pos = exifData.findKey(ExifKey(std::string("Exif.") + group_ + ".ImageLength"));
|
554 |
|
if (pos != exifData.end()) {
|
555 |
|
height_ = pos->value().toLong();
|
|
554 |
if (pos != exifData.end() && pos->count() > 0) {
|
|
555 |
height_ = pos->toLong();
|
556 |
556 |
}
|
557 |
557 |
|
558 |
558 |
if (width_ == 0 || height_ == 0) return;
|
... | ... | |
631 |
631 |
|
632 |
632 |
const Value &sizes = preview["Exif.Image." + sizeTag_].value();
|
633 |
633 |
|
634 |
|
if (sizes.count() == 1) {
|
635 |
|
// this saves one copying of the buffer
|
636 |
|
uint32_t offset = dataValue.toLong(0);
|
637 |
|
uint32_t size = sizes.toLong(0);
|
638 |
|
if (offset + size <= static_cast<uint32_t>(io.size()))
|
639 |
|
dataValue.setDataArea(base + offset, size);
|
640 |
|
}
|
641 |
|
else {
|
642 |
|
// FIXME: the buffer is probably copied twice, it should be optimized
|
643 |
|
DataBuf buf(size_);
|
644 |
|
Exiv2::byte* pos = buf.pData_;
|
645 |
|
for (int i = 0; i < sizes.count(); i++) {
|
646 |
|
uint32_t offset = dataValue.toLong(i);
|
647 |
|
uint32_t size = sizes.toLong(i);
|
|
634 |
if (sizes.count() == dataValue.count()) {
|
|
635 |
if (sizes.count() == 1) {
|
|
636 |
// this saves one copying of the buffer
|
|
637 |
uint32_t offset = dataValue.toLong(0);
|
|
638 |
uint32_t size = sizes.toLong(0);
|
648 |
639 |
if (offset + size <= static_cast<uint32_t>(io.size()))
|
649 |
|
memcpy(pos, base + offset, size);
|
650 |
|
pos += size;
|
|
640 |
dataValue.setDataArea(base + offset, size);
|
651 |
641 |
}
|
652 |
|
dataValue.setDataArea(buf.pData_, buf.size_);
|
|
642 |
else {
|
|
643 |
// FIXME: the buffer is probably copied twice, it should be optimized
|
|
644 |
DataBuf buf(size_);
|
|
645 |
Exiv2::byte* pos = buf.pData_;
|
|
646 |
for (int i = 0; i < sizes.count(); i++) {
|
|
647 |
uint32_t offset = dataValue.toLong(i);
|
|
648 |
uint32_t size = sizes.toLong(i);
|
|
649 |
if (offset + size <= static_cast<uint32_t>(io.size()))
|
|
650 |
memcpy(pos, base + offset, size);
|
|
651 |
pos += size;
|
|
652 |
}
|
|
653 |
dataValue.setDataArea(buf.pData_, buf.size_);
|
|
654 |
}
|
653 |
655 |
}
|
654 |
656 |
}
|
655 |
657 |
|