Changeset View
Changeset View
Standalone View
Standalone View
lib/thumbnailprovider/thumbnailgenerator.cpp
Show All 16 Lines | |||||
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. | 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. | ||
19 | 19 | | |||
20 | */ | 20 | */ | ||
21 | // Self | 21 | // Self | ||
22 | #include "thumbnailgenerator.h" | 22 | #include "thumbnailgenerator.h" | ||
23 | 23 | | |||
24 | // Local | 24 | // Local | ||
25 | #include "imageutils.h" | | |||
26 | #include "jpegcontent.h" | 25 | #include "jpegcontent.h" | ||
27 | #include "gwenviewconfig.h" | 26 | #include "gwenviewconfig.h" | ||
28 | #include "exiv2imageloader.h" | 27 | #include "exiv2imageloader.h" | ||
29 | 28 | | |||
30 | // KDE | 29 | // KDE | ||
31 | #include <QDebug> | 30 | #include <QDebug> | ||
32 | #ifdef KDCRAW_FOUND | 31 | #ifdef KDCRAW_FOUND | ||
33 | #include <kdcraw/kdcraw.h> | 32 | #include <kdcraw/kdcraw.h> | ||
Show All 22 Lines | |||||
56 | // | 55 | // | ||
57 | // ThumbnailContext | 56 | // ThumbnailContext | ||
58 | // | 57 | // | ||
59 | //------------------------------------------------------------------------ | 58 | //------------------------------------------------------------------------ | ||
60 | bool ThumbnailContext::load(const QString &pixPath, int pixelSize) | 59 | bool ThumbnailContext::load(const QString &pixPath, int pixelSize) | ||
61 | { | 60 | { | ||
62 | mImage = QImage(); | 61 | mImage = QImage(); | ||
63 | mNeedCaching = true; | 62 | mNeedCaching = true; | ||
64 | Orientation orientation = NORMAL; | | |||
65 | QImage originalImage; | 63 | QImage originalImage; | ||
66 | QSize originalSize; | 64 | QSize originalSize; | ||
67 | 65 | | |||
68 | QByteArray formatHint = pixPath.section(QLatin1Char('.'), -1).toLocal8Bit().toLower(); | 66 | QByteArray formatHint = pixPath.section(QLatin1Char('.'), -1).toLocal8Bit().toLower(); | ||
69 | QImageReader reader(pixPath); | 67 | QImageReader reader(pixPath); | ||
70 | 68 | | |||
71 | JpegContent content; | 69 | JpegContent content; | ||
72 | QByteArray format; | 70 | QByteArray format; | ||
Show All 40 Lines | 106 | #endif | |||
113 | } | 111 | } | ||
114 | 112 | | |||
115 | if (reader.format() == "jpeg" && GwenviewConfig::applyExifOrientation()) { | 113 | if (reader.format() == "jpeg" && GwenviewConfig::applyExifOrientation()) { | ||
116 | content.load(pixPath); | 114 | content.load(pixPath); | ||
117 | } | 115 | } | ||
118 | } | 116 | } | ||
119 | 117 | | |||
120 | // If there's jpeg content (from jpg or raw files), try to load an embedded thumbnail, if available. | 118 | // If there's jpeg content (from jpg or raw files), try to load an embedded thumbnail, if available. | ||
121 | // If applyExifOrientation is not set, don't use the | 119 | if (!content.rawData().isEmpty()) { | ||
122 | // embedded thumbnail since it might be rotated differently | | |||
123 | // than the actual image | | |||
124 | if (!content.rawData().isEmpty() && GwenviewConfig::applyExifOrientation()) { | | |||
125 | QImage thumbnail = content.thumbnail(); | 120 | QImage thumbnail = content.thumbnail(); | ||
126 | orientation = content.orientation(); | | |||
127 | 121 | | |||
128 | if (qMax(thumbnail.width(), thumbnail.height()) >= pixelSize) { | 122 | if (qMax(thumbnail.width(), thumbnail.height()) >= pixelSize) { | ||
129 | mImage = thumbnail; | 123 | mImage = std::move(thumbnail); | ||
130 | if (orientation != NORMAL && orientation != NOT_AVAILABLE) { | | |||
131 | QTransform matrix = ImageUtils::transformMatrix(orientation); | | |||
132 | mImage = mImage.transformed(matrix); | | |||
133 | } | | |||
134 | mOriginalWidth = content.size().width(); | 124 | mOriginalWidth = content.size().width(); | ||
135 | mOriginalHeight = content.size().height(); | 125 | mOriginalHeight = content.size().height(); | ||
136 | return true; | 126 | return true; | ||
137 | } | 127 | } | ||
138 | } | 128 | } | ||
139 | 129 | | |||
140 | // Generate thumbnail from full image | 130 | // Generate thumbnail from full image | ||
141 | originalSize = reader.size(); | 131 | originalSize = reader.size(); | ||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |