Changeset View
Changeset View
Standalone View
Standalone View
lib/jpegcontent.cpp
Show First 20 Lines • Show All 568 Lines • ▼ Show 20 Line(s) | |||||
569 | #if(EXIV2_TEST_VERSION(0,17,91)) | 569 | #if(EXIV2_TEST_VERSION(0,17,91)) | ||
570 | Exiv2::ExifThumbC thumb(d->mExifData); | 570 | Exiv2::ExifThumbC thumb(d->mExifData); | ||
571 | Exiv2::DataBuf thumbnail = thumb.copy(); | 571 | Exiv2::DataBuf thumbnail = thumb.copy(); | ||
572 | #else | 572 | #else | ||
573 | Exiv2::DataBuf thumbnail = d->mExifData.copyThumbnail(); | 573 | Exiv2::DataBuf thumbnail = d->mExifData.copyThumbnail(); | ||
574 | #endif | 574 | #endif | ||
575 | image.loadFromData(thumbnail.pData_, thumbnail.size_); | 575 | image.loadFromData(thumbnail.pData_, thumbnail.size_); | ||
576 | 576 | | |||
577 | Exiv2::ExifKey key("Exif.Canon.ThumbnailImageValidArea"); | 577 | Exiv2::ExifData::iterator it = d->mExifData.findKey(Exiv2::ExifKey("Exif.Canon.ThumbnailImageValidArea")); | ||
578 | Exiv2::ExifData::iterator it = d->mExifData.findKey(key); | | |||
579 | | ||||
580 | // ensure ThumbnailImageValidArea actually specifies a rectangle, i.e. there must be 4 coordinates | 578 | // ensure ThumbnailImageValidArea actually specifies a rectangle, i.e. there must be 4 coordinates | ||
581 | if (it != d->mExifData.end() && it->count() == 4) { | 579 | if (it != d->mExifData.end() && it->count() == 4) { | ||
582 | QRect validArea(QPoint(it->toLong(0), it->toLong(2)), QPoint(it->toLong(1), it->toLong(3))); | 580 | QRect validArea(QPoint(it->toLong(0), it->toLong(2)), QPoint(it->toLong(1), it->toLong(3))); | ||
583 | image = image.copy(validArea); | 581 | image = image.copy(validArea); | ||
582 | } else { | ||||
583 | // Unfortunately, Sony does not provide an exif tag that specifies the valid area of the | ||||
584 | // embedded thumbnail. Need to derive it from the size of the preview image instead. | ||||
585 | it = d->mExifData.findKey(Exiv2::ExifKey("Exif.Sony1.PreviewImageSize")); | ||||
586 | if (it != d->mExifData.end() && it->count() == 2) { | ||||
587 | const long prevHeight = it->toLong(0); | ||||
588 | const long prevWidth = it->toLong(1); | ||||
589 | | ||||
590 | const double scale = prevWidth / image.width(); | ||||
cfeck: This division causes bug 414631. | |||||
Submitted D26527 to fix this. ngraham: Submitted D26527 to fix this. | |||||
591 | | ||||
592 | // the embedded thumb only needs to be cropped vertically | ||||
593 | const long validThumbAreaHeight = ceil(prevHeight / scale); | ||||
594 | const long totalHeightOfBlackArea = image.height() - validThumbAreaHeight; | ||||
595 | // black bars on top and bottom should be equal in height | ||||
596 | const long offsetFromTop = totalHeightOfBlackArea / 2; | ||||
597 | | ||||
598 | const QRect validArea(QPoint(0, offsetFromTop), QSize(image.width(), validThumbAreaHeight)); | ||||
599 | image = image.copy(validArea); | ||||
600 | } | ||||
584 | } | 601 | } | ||
585 | 602 | | |||
586 | Orientation o = orientation(); | 603 | Orientation o = orientation(); | ||
587 | if (GwenviewConfig::applyExifOrientation() && o != NORMAL && o != NOT_AVAILABLE) { | 604 | if (GwenviewConfig::applyExifOrientation() && o != NORMAL && o != NOT_AVAILABLE) { | ||
588 | image = image.transformed(ImageUtils::transformMatrix(o)); | 605 | image = image.transformed(ImageUtils::transformMatrix(o)); | ||
589 | } | 606 | } | ||
590 | } | 607 | } | ||
591 | return image; | 608 | return image; | ||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
This division causes bug 414631.