OSDN Git Service

gwenview: assume QImage plugin for RAW format is provided
authorIvailo Monev <xakepa10@gmail.com>
Sat, 31 Jul 2021 19:23:51 +0000 (22:23 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 31 Jul 2021 19:24:45 +0000 (22:24 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
gwenview/CMakeLists.txt
gwenview/lib/CMakeLists.txt
gwenview/lib/document/loadingdocumentimpl.cpp
gwenview/tests/auto/CMakeLists.txt
gwenview/tests/auto/documenttest.cpp

index 67ec367..1f46e9d 100644 (file)
@@ -34,7 +34,6 @@ set_package_properties(LibKonq PROPERTIES
 include_directories(
     ${QDBUS_INCLUDE_DIRS}
     ${EXIV2_INCLUDE_DIR}
-    ${KDCRAW_INCLUDE_DIR}
     # for gwenview_export.h
     ${CMAKE_CURRENT_BINARY_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}/lib
index 21e1e98..9d577e1 100644 (file)
@@ -118,7 +118,6 @@ generate_export_header(gwenviewlib)
 target_link_libraries(gwenviewlib
     ${KDE4_KFILE_LIBS}
     ${KDE4_KIO_LIBS}
-    ${KDE4_KDCRAW_LIBS}
     ${EXIV2_LIBRARIES}
     ${X11_X11_LIB}
 )
index 8d74ea5..1c09097 100644 (file)
@@ -43,7 +43,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #include <KMimeType>
 #include <KProtocolInfo>
 #include <KUrl>
-#include <libkdcraw/kdcraw.h>
 
 // Local
 #include "animateddocumentloadedimpl.h"
@@ -177,58 +176,31 @@ struct LoadingDocumentImplPrivate
         buffer.setBuffer(&mData);
         buffer.open(QIODevice::ReadOnly);
 
-        if (KDcrawIface::KDcraw::rawFilesList().contains(QString(mFormatHint))) {
-            QByteArray previewData;
-
-            // use KDcraw for getting the embedded preview
-            // KDcraw functionality cloned locally (temp. solution)
-            bool ret = KDcrawIface::KDcraw::loadEmbeddedPreview(previewData, buffer);
-
-            QImage originalImage;
-            if (!ret || !originalImage.loadFromData(previewData) || qMin(originalImage.width(), originalImage.height()) < MIN_PREV_SIZE) {
-                // if the embedded preview loading failed or gets just a small image, load
-                // half preview instead. That's slower but it works even for images containing
-                // small (160x120px) or none embedded preview.
-                if (!KDcrawIface::KDcraw::loadHalfPreview(previewData, buffer)) {
-                    kWarning() << "unable to get half preview for " << q->document()->url().fileName();
-                    return false;
-                }
-            }
-
-            buffer.close();
-
-            // now it's safe to replace mData with the jpeg data
-            mData = previewData;
-
-            // need to fill mFormat so gwenview can tell the type when trying to save
-            mFormat = mFormatHint;
-        } else {
-            QImageReader reader(&buffer, mFormatHint);
-            mImageSize = reader.size();
+        QImageReader reader(&buffer, mFormatHint);
+        mImageSize = reader.size();
 
+        if (!reader.canRead()) {
+            kWarning() << "QImageReader::read() using format hint" << mFormatHint << "failed:" << reader.errorString();
+            if (buffer.pos() != 0) {
+                kWarning() << "A bad Qt image decoder moved the buffer to" << buffer.pos() << "in a call to canRead()! Rewinding.";
+                buffer.seek(0);
+            }
+            reader.setFormat(QByteArray());
+            // Set buffer again, otherwise QImageReader won't restart from scratch
+            reader.setDevice(&buffer);
             if (!reader.canRead()) {
-                kWarning() << "QImageReader::read() using format hint" << mFormatHint << "failed:" << reader.errorString();
-                if (buffer.pos() != 0) {
-                    kWarning() << "A bad Qt image decoder moved the buffer to" << buffer.pos() << "in a call to canRead()! Rewinding.";
-                    buffer.seek(0);
-                }
-                reader.setFormat(QByteArray());
-                // Set buffer again, otherwise QImageReader won't restart from scratch
-                reader.setDevice(&buffer);
-                if (!reader.canRead()) {
-                    kWarning() << "QImageReader::read() without format hint failed:" << reader.errorString();
-                    return false;
-                }
-                kWarning() << "Image format is actually" << reader.format() << "not" << mFormatHint;
+                kWarning() << "QImageReader::read() without format hint failed:" << reader.errorString();
+                return false;
             }
+            kWarning() << "Image format is actually" << reader.format() << "not" << mFormatHint;
+        }
 
-            mFormat = reader.format();
+        mFormat = reader.format();
 
-            if (mFormat == "jpg") {
-                // if mFormatHint was "jpg", then mFormat is "jpg", but the rest of
-                // Gwenview code assumes JPEG images have "jpeg" format.
-                mFormat = "jpeg";
-            }
+        if (mFormat == "jpg") {
+            // if mFormatHint was "jpg", then mFormat is "jpg", but the rest of
+            // Gwenview code assumes JPEG images have "jpeg" format.
+            mFormat = "jpeg";
         }
 
         LOG("mFormat" << mFormat);
index 9b9192f..3ae9689 100644 (file)
@@ -4,7 +4,6 @@ macro(gv_add_unit_test _test)
         ${KDE4_KIO_LIBS}
         ${KDE4_KDEUI_LIBS}
         ${KDE4_KDECORE_LIBS}
-        ${KDE4_KDCRAW_LIBS}
         ${QT_QTTEST_LIBRARY}
         ${QT_QTCORE_LIBRARY}
         ${QT_QTGUI_LIBRARY}
index 24af83d..548b2de 100644 (file)
@@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include <KJobUiDelegate>
 #include <KIO/NetAccess>
 #include <qtest_kde.h>
-#include <libkdcraw/kdcraw.h>
 
 // Local
 #include "../lib/abstractimageoperation.h"
@@ -84,15 +83,6 @@ void DocumentTest::testLoad()
 
     KUrl url = urlForTestFile(fileName);
 
-    // testing RAW loading. For raw, QImage directly won't work -> load it using KDCRaw
-    QByteArray mFormatHint = url.fileName().section('.', -1).toAscii().toLower();
-    if (KDcrawIface::KDcraw::rawFilesList().contains(QString(mFormatHint))) {
-        if (!KDcrawIface::KDcraw::loadEmbeddedPreview(expectedImage, url.toLocalFile())) {
-            QSKIP("Not running this test: failed to get expectedImage. Try running ./fetch_testing_raw.sh\
- in the tests/data directory and then rerun the tests.", SkipSingle);
-        }
-    }
-
     if (expectedKind != MimeTypeUtils::KIND_SVG_IMAGE) {
         if (expectedImage.isNull()) {
             QSKIP("Not running this test: QImage failed to load the test image", SkipSingle);
@@ -372,10 +362,6 @@ void DocumentTest::testLoadRotated()
 
     // RAW preview on rotated image
     url = urlForTestFile("dsd_1838.nef");
-    if (!KDcrawIface::KDcraw::loadEmbeddedPreview(image, url.toLocalFile())) {
-        QSKIP("Not running this test: failed to get image. Try running ./fetch_testing_raw.sh\
- in the tests/data directory and then rerun the tests.", SkipSingle);
-    }
     matrix = ImageUtils::transformMatrix(ROT_270);
     image = image.transformed(matrix);