Changeset View
Changeset View
Standalone View
Standalone View
lib/thumbnailprovider/thumbnailgenerator.cpp
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
| 44 | #undef LOG | 44 | #undef LOG | ||
| 45 | //#define ENABLE_LOG | 45 | //#define ENABLE_LOG | ||
| 46 | #ifdef ENABLE_LOG | 46 | #ifdef ENABLE_LOG | ||
| 47 | #define LOG(x) //qDebug() << x | 47 | #define LOG(x) //qDebug() << x | ||
| 48 | #else | 48 | #else | ||
| 49 | #define LOG(x) ; | 49 | #define LOG(x) ; | ||
| 50 | #endif | 50 | #endif | ||
| 51 | 51 | | |||
| 52 | const int MIN_PREV_SIZE = 1000; | | |||
| 53 | | ||||
| 54 | //------------------------------------------------------------------------ | 52 | //------------------------------------------------------------------------ | ||
| 55 | // | 53 | // | ||
| 56 | // ThumbnailContext | 54 | // ThumbnailContext | ||
| 57 | // | 55 | // | ||
| 58 | //------------------------------------------------------------------------ | 56 | //------------------------------------------------------------------------ | ||
| 59 | bool ThumbnailContext::load(const QString &pixPath, int pixelSize) | 57 | bool ThumbnailContext::load(const QString &pixPath, int pixelSize) | ||
| 60 | { | 58 | { | ||
| 61 | mImage = QImage(); | 59 | mImage = QImage(); | ||
| Show All 13 Lines | |||||
| 75 | #ifdef KDCRAW_FOUND | 73 | #ifdef KDCRAW_FOUND | ||
| 76 | // raw images deserve special treatment | 74 | // raw images deserve special treatment | ||
| 77 | if (KDcrawIface::KDcraw::rawFilesList().contains(QString::fromLatin1(formatHint))) { | 75 | if (KDcrawIface::KDcraw::rawFilesList().contains(QString::fromLatin1(formatHint))) { | ||
| 78 | // use KDCraw to extract the preview | 76 | // use KDCraw to extract the preview | ||
| 79 | bool ret = KDcrawIface::KDcraw::loadEmbeddedPreview(data, pixPath); | 77 | bool ret = KDcrawIface::KDcraw::loadEmbeddedPreview(data, pixPath); | ||
| 80 | 78 | | |||
| 81 | // We need QImage. Loading JpegContent from QImage - exif lost | 79 | // We need QImage. Loading JpegContent from QImage - exif lost | ||
| 82 | // Loading QImage from JpegContent - unimplemented, would go with loadFromData | 80 | // Loading QImage from JpegContent - unimplemented, would go with loadFromData | ||
| 83 | if (!ret || !originalImage.loadFromData(data) || qMin(originalImage.width(), originalImage.height()) < MIN_PREV_SIZE) { | 81 | if (!ret) { | ||
| 84 | // if the embedded preview loading failed or gets just a small image, load | 82 | // if the embedded preview loading failed, load half preview instead. That's slower... | ||
| 85 | // half preview instead. That's slower... | | |||
| 86 | if (!KDcrawIface::KDcraw::loadHalfPreview(data, pixPath)) { | 83 | if (!KDcrawIface::KDcraw::loadHalfPreview(data, pixPath)) { | ||
| 87 | qWarning() << "unable to get preview for " << pixPath.toUtf8().constData(); | 84 | qWarning() << "unable to get preview for " << pixPath.toUtf8().constData(); | ||
| 88 | return false; | 85 | return false; | ||
| 89 | } | 86 | } | ||
| 90 | previewRatio = 2; | 87 | previewRatio = 2; | ||
| 91 | } | 88 | } | ||
| 92 | 89 | | |||
| 93 | // And we need JpegContent too because of EXIF (orientation!). | 90 | // And we need JpegContent too because of EXIF (orientation!). | ||
| ▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines | |||||