diff --git a/src/imageformats/raw.cpp b/src/imageformats/raw.cpp index c8888fe..3b40d6b 100644 --- a/src/imageformats/raw.cpp +++ b/src/imageformats/raw.cpp @@ -443,7 +443,9 @@ void setParams(QImageIOHandler *handler, LibRaw *rawProcessor) auto &&rawparams = rawProcessor->imgdata.rawparams; #endif // Select one raw image from input file (0 - first, ...) - rawparams.shot_select = handler->currentImageNumber(); + if (handler->currentImageNumber() > -1) { + rawparams.shot_select = handler->currentImageNumber(); + } // *** Set processing parameters @@ -723,6 +725,7 @@ RAWHandler::RAWHandler() : m_imageNumber(0) , m_imageCount(0) , m_quality(-1) + , m_startPos(-1) { } @@ -739,6 +742,15 @@ bool RAWHandler::read(QImage *image) { auto dev = device(); + // set the image position after the first run. + if (!dev->isSequential()) { + if (m_startPos < 0) { + m_startPos = dev->pos(); + } else { + dev->seek(m_startPos); + } + } + // Check image file format. if (dev->atEnd()) { return false; @@ -820,7 +832,7 @@ bool RAWHandler::jumpToNextImage() bool RAWHandler::jumpToImage(int imageNumber) { - if (imageNumber >= imageCount()) { + if (imageNumber < 0 || imageNumber >= imageCount()) { return false; } m_imageNumber = imageNumber; diff --git a/src/imageformats/raw_p.h b/src/imageformats/raw_p.h index 30e8357..b4c5451 100644 --- a/src/imageformats/raw_p.h +++ b/src/imageformats/raw_p.h @@ -78,6 +78,12 @@ private: * @note It is safe to set both W and A: W is used if camera white balance is found, otherwise A is used. */ qint32 m_quality; + + /*! + * \brief m_startPos + * The initial device position to allow multi image load (cache value). + */ + qint64 m_startPos; }; class RAWPlugin : public QImageIOPlugin