Get rid of QPixmap
This commit is contained in:
+22
-39
@@ -75,9 +75,9 @@ void printStarModel(int radius, const std::vector<double> &data, const Star &sta
|
||||
std::cout << m.toStdString() << std::endl << std::endl;
|
||||
}
|
||||
|
||||
bool loadRAW(QString path, ImageInfoData &info, RawImage **image, QImage *qimage)
|
||||
bool loadRAW(QString path, ImageInfoData &info, RawImage **image)
|
||||
{
|
||||
if(!image && !qimage)
|
||||
if(!image)
|
||||
return false;
|
||||
|
||||
LibRaw raw;
|
||||
@@ -112,41 +112,24 @@ bool loadRAW(QString path, ImageInfoData &info, RawImage **image, QImage *qimage
|
||||
memcpy((*image)->data(), &out[0], sizeof(uint16_t)*d);
|
||||
}
|
||||
|
||||
if(qimage)
|
||||
QString shutterSpeed = QString::number(raw.imgdata.other.shutter);
|
||||
if(raw.imgdata.other.shutter < 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
QString shutterSpeed = QString::number(raw.imgdata.other.shutter);
|
||||
if(raw.imgdata.other.shutter < 1)
|
||||
{
|
||||
shutterSpeed = QString("1/%1s").arg(1.0f/raw.imgdata.other.shutter);
|
||||
}
|
||||
info.append(StringPair(QObject::tr("Width"), QString::number(rawImg->width)));
|
||||
info.append(StringPair(QObject::tr("Height"), QString::number(rawImg->height)));
|
||||
info.append(StringPair(QObject::tr("ISO"), QString::number(raw.imgdata.other.iso_speed)));
|
||||
info.append(StringPair(QObject::tr("Shutter speed"), shutterSpeed));
|
||||
#if LIBRAW_MINOR_VERSION>=19
|
||||
info.append(StringPair(QObject::tr("Camera temperature"), QString::number(raw.imgdata.other.CameraTemperature)));
|
||||
#endif
|
||||
raw.dcraw_clear_mem(rawImg);
|
||||
|
||||
*qimage = img;
|
||||
shutterSpeed = QString("1/%1s").arg(1.0f/raw.imgdata.other.shutter);
|
||||
}
|
||||
|
||||
//info.append(StringPair(QObject::tr("Width"), QString::number(rawImg->width)));
|
||||
//info.append(StringPair(QObject::tr("Height"), QString::number(rawImg->height)));
|
||||
info.append(StringPair(QObject::tr("ISO"), QString::number(raw.imgdata.other.iso_speed)));
|
||||
info.append(StringPair(QObject::tr("Shutter speed"), shutterSpeed));
|
||||
#if LIBRAW_MINOR_VERSION>=19
|
||||
info.append(StringPair(QObject::tr("Camera temperature"), QString::number(raw.imgdata.other.CameraTemperature)));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool loadFITS(QString path, ImageInfoData &info, RawImage **image, QImage *qimage)
|
||||
bool loadFITS(QString path, ImageInfoData &info, RawImage **image)
|
||||
{
|
||||
if(!image && !qimage)
|
||||
if(!image)
|
||||
return false;
|
||||
|
||||
fitsfile *file;
|
||||
@@ -246,23 +229,22 @@ void LoadRunable::run()
|
||||
QFileInfo finfo(m_file);
|
||||
info.append(StringPair(QObject::tr("Filename"), finfo.fileName()));
|
||||
|
||||
QImage img;
|
||||
RawImage *rawImage = nullptr;
|
||||
bool raw = false;
|
||||
if(m_file.endsWith(".CR2", Qt::CaseInsensitive))
|
||||
{
|
||||
timer.start();
|
||||
loadRAW(m_file, info, &rawImage, nullptr);
|
||||
loadRAW(m_file, info, &rawImage);
|
||||
raw = true;
|
||||
qDebug() << "LoadRaw" << timer.elapsed();
|
||||
}
|
||||
else if(m_file.endsWith(".FIT", Qt::CaseInsensitive) || m_file.endsWith(".FITS", Qt::CaseInsensitive))
|
||||
{
|
||||
loadFITS(m_file, info, &rawImage, nullptr);
|
||||
loadFITS(m_file, info, &rawImage);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = QImage(m_file);
|
||||
QImage img(m_file);
|
||||
ExifData *exif = exif_data_new_from_file(m_file.toLocal8Bit().constData());
|
||||
info.append(StringPair(QObject::tr("Width"), QString::number(img.width())));
|
||||
info.append(StringPair(QObject::tr("Height"), QString::number(img.height())));
|
||||
@@ -272,6 +254,7 @@ void LoadRunable::run()
|
||||
loadExifEntry(info, exif->ifd[EXIF_IFD_EXIF], EXIF_TAG_SHUTTER_SPEED_VALUE);
|
||||
exif_data_free(exif);
|
||||
}
|
||||
rawImage = new RawImage(img);
|
||||
}
|
||||
|
||||
if(rawImage && m_analyzeLevel >= Statistics)
|
||||
@@ -299,8 +282,8 @@ void LoadRunable::run()
|
||||
int numPeaks = medianImage->findPeaks(median+stdDev*2, 20, peaks);
|
||||
delete medianImage;
|
||||
qDebug() << "peaks" << timer.restart();
|
||||
if(m_analyzeLevel == Peaks)
|
||||
drawPeaks(img, peaks);
|
||||
//if(m_analyzeLevel == Peaks)
|
||||
// drawPeaks(img, peaks);
|
||||
qDebug() << "draw peaks" << timer.restart();
|
||||
info.append(StringPair(QObject::tr("Peaks"), QString::number(numPeaks)));
|
||||
info.append(StringPair(QObject::tr("Peaks draw"), QString::number(peaks.size())));
|
||||
@@ -330,7 +313,7 @@ void LoadRunable::run()
|
||||
stars.push_back(star);
|
||||
}
|
||||
}
|
||||
drawStars(img, stars);
|
||||
//drawStars(img, stars);
|
||||
info.append(StringPair(QObject::tr("FWHM X"), QString::number(fwhmX/stars.size())));
|
||||
info.append(StringPair(QObject::tr("FWHM Y"), QString::number(fwhmY/stars.size())));
|
||||
}
|
||||
@@ -338,5 +321,5 @@ void LoadRunable::run()
|
||||
}
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(QImage, img), Q_ARG(void*, rawImage), Q_ARG(ImageInfoData, info));
|
||||
QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(void*, rawImage), Q_ARG(ImageInfoData, info));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user