Changeset View
Changeset View
Standalone View
Standalone View
lib/jpegcontent.cpp
Context not available. | |||||
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 | long prevHeight = it->toLong(0); | ||||
588 | long prevWidth = it->toLong(1); | ||||
589 | | ||||
590 | 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 | long validThumbAreaHeight = ceil(prevHeight / scale); | ||||
594 | long totalHeightOfBlackArea = image.height() - validThumbAreaHeight; | ||||
595 | // black bars on top and bottom should be equal in height | ||||
596 | long offsetFromTop = totalHeightOfBlackArea / 2; | ||||
597 | | ||||
598 | 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(); | ||
Context not available. |
This division causes bug 414631.