Do not load images that were already released
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include "loadrunable.h"
|
||||
#include "imageringlist.h"
|
||||
#include <libraw/libraw.h>
|
||||
|
||||
LoadRunable::LoadRunable(const QString &file, Image *receiver) :
|
||||
m_file(file),
|
||||
m_receiver(receiver)
|
||||
{
|
||||
}
|
||||
|
||||
void LoadRunable::run()
|
||||
{
|
||||
if(!m_receiver->isCurrent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
uint scanLine = rawImg->width*rawImg->colors;
|
||||
for(uint i=0; i<rawImg->height; 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user