diff --git a/imageringlist.cpp b/imageringlist.cpp index 642a9f7..ee21eea 100644 --- a/imageringlist.cpp +++ b/imageringlist.cpp @@ -1,6 +1,8 @@ #include "imageringlist.h" #include #include +#include +#include using namespace std; @@ -18,8 +20,31 @@ public: } void run() { - QImage img(m_file); - QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(QImage, img)); + if(m_file.endsWith(".CR2", Qt::CaseInsensitive)) + { + LibRaw raw; + raw.open_file(m_file.toLocal8Bit().data()); + raw.imgdata.params.half_size = true; + raw.imgdata.params.use_camera_wb = true; + raw.imgdata.params.user_flip = 0; + raw.unpack(); + raw.dcraw_process(); + libraw_processed_image_t *rawImg = raw.dcraw_make_mem_image(); + QImage img(rawImg->width, rawImg->height, QImage::Format_RGB888); + qDebug() << rawImg->width << img.width()*3 << img.scanLine(1)-img.scanLine(0); + uint scanLine = rawImg->width*rawImg->colors; + for(uint i=0; iheight; i++) + { + memcpy(img.scanLine(i), rawImg->data+(i*scanLine), scanLine); + } + raw.dcraw_clear_mem(rawImg); + QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(QImage, img)); + } + else + { + QImage img(m_file); + QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(QImage, img)); + } } }; @@ -80,7 +105,7 @@ bool ImageRingList::setDir(const QString path, const QString ¤tFile) if(dir.exists()) { QStringList nameFilter; - nameFilter << "*.jpg" << "*.png"; + nameFilter << "*.jpg" << "*.png" << "*.cr2"; QStringList list = dir.entryList(nameFilter, QDir::Files | QDir::Readable, QDir::Name); QStringList absolutePaths; diff --git a/imageselector.pro b/imageselector.pro index 6b24534..39ade6a 100644 --- a/imageselector.pro +++ b/imageselector.pro @@ -13,6 +13,8 @@ TEMPLATE = app CONFIG += c++11 +LIBS += -lraw + SOURCES += main.cpp\ mainwindow.cpp \ imagescrollarea.cpp \ diff --git a/mainwindow.cpp b/mainwindow.cpp index 2551766..ac9a33c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -139,7 +139,7 @@ void MainWindow::openFile() if(standardLocations.size()) path = standardLocations.first(); - QString file = QFileDialog::getOpenFileName(this, tr("Open file"), path, tr("Images (*.jpg *.png *.JPG *.PNG)")); + QString file = QFileDialog::getOpenFileName(this, tr("Open file"), path, tr("Images (*.jpg *.png *.cr2 *.JPG *.PNG *.CR2)")); if(!file.isEmpty()) { QFileInfo info(file);