Changeset View
Changeset View
Standalone View
Standalone View
lib/jpegcontent.cpp
Show First 20 Lines • Show All 582 Lines • ▼ Show 20 Line(s) | 575 | #endif | |||
---|---|---|---|---|---|
583 | } else { | 583 | } else { | ||
584 | // Unfortunately, Sony does not provide an exif tag that specifies the valid area of the | 584 | // Unfortunately, Sony does not provide an exif tag that specifies the valid area of the | ||
585 | // embedded thumbnail. Need to derive it from the size of the preview image instead. | 585 | // embedded thumbnail. Need to derive it from the size of the preview image instead. | ||
586 | it = d->mExifData.findKey(Exiv2::ExifKey("Exif.Sony1.PreviewImageSize")); | 586 | it = d->mExifData.findKey(Exiv2::ExifKey("Exif.Sony1.PreviewImageSize")); | ||
587 | if (it != d->mExifData.end() && it->count() == 2) { | 587 | if (it != d->mExifData.end() && it->count() == 2) { | ||
588 | const long prevHeight = it->toLong(0); | 588 | const long prevHeight = it->toLong(0); | ||
589 | const long prevWidth = it->toLong(1); | 589 | const long prevWidth = it->toLong(1); | ||
590 | 590 | | |||
591 | if (image.width() > 0 && prevWidth > 0 ) { | ||||
591 | const double scale = prevWidth / image.width(); | 592 | const double scale = prevWidth / image.width(); | ||
592 | 593 | | |||
593 | // the embedded thumb only needs to be cropped vertically | 594 | // the embedded thumb only needs to be cropped vertically | ||
594 | const long validThumbAreaHeight = ceil(prevHeight / scale); | 595 | const long validThumbAreaHeight = ceil(prevHeight / scale); | ||
595 | const long totalHeightOfBlackArea = image.height() - validThumbAreaHeight; | 596 | const long totalHeightOfBlackArea = image.height() - validThumbAreaHeight; | ||
596 | // black bars on top and bottom should be equal in height | 597 | // black bars on top and bottom should be equal in height | ||
597 | const long offsetFromTop = totalHeightOfBlackArea / 2; | 598 | const long offsetFromTop = totalHeightOfBlackArea / 2; | ||
598 | 599 | | |||
599 | const QRect validArea(QPoint(0, offsetFromTop), QSize(image.width(), validThumbAreaHeight)); | 600 | const QRect validArea(QPoint(0, offsetFromTop), QSize(image.width(), validThumbAreaHeight)); | ||
600 | image = image.copy(validArea); | 601 | image = image.copy(validArea); | ||
601 | } | 602 | } | ||
602 | } | 603 | } | ||
604 | } | ||||
603 | 605 | | |||
604 | Orientation o = orientation(); | 606 | Orientation o = orientation(); | ||
605 | if (GwenviewConfig::applyExifOrientation() && o != NORMAL && o != NOT_AVAILABLE) { | 607 | if (GwenviewConfig::applyExifOrientation() && o != NORMAL && o != NOT_AVAILABLE) { | ||
606 | image = image.transformed(ImageUtils::transformMatrix(o)); | 608 | image = image.transformed(ImageUtils::transformMatrix(o)); | ||
607 | } | 609 | } | ||
608 | } | 610 | } | ||
609 | return image; | 611 | return image; | ||
610 | } | 612 | } | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |