2021-11-18 14:58:01 +00:00
|
|
|
#include "turnaround_loader.h"
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QGuiApplication>
|
2018-03-13 06:39:36 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
TurnaroundLoader::TurnaroundLoader(const QString& filename, QSize viewSize)
|
2018-03-13 06:39:36 +00:00
|
|
|
{
|
|
|
|
m_filename = filename;
|
|
|
|
m_viewSize = viewSize;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
TurnaroundLoader::TurnaroundLoader(const QImage& image, QSize viewSize)
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
|
|
|
m_inputImage = image;
|
|
|
|
m_viewSize = viewSize;
|
|
|
|
}
|
|
|
|
|
2018-03-13 06:39:36 +00:00
|
|
|
TurnaroundLoader::~TurnaroundLoader()
|
|
|
|
{
|
|
|
|
delete m_resultImage;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QImage* TurnaroundLoader::takeResultImage()
|
2018-03-13 06:39:36 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
QImage* returnImage = m_resultImage;
|
2018-04-07 08:44:39 +00:00
|
|
|
m_resultImage = nullptr;
|
2018-03-13 06:39:36 +00:00
|
|
|
return returnImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TurnaroundLoader::process()
|
|
|
|
{
|
2018-04-07 08:44:39 +00:00
|
|
|
if (m_inputImage.isNull()) {
|
|
|
|
QImage image(m_filename);
|
|
|
|
m_resultImage = new QImage(image.scaled(m_viewSize, Qt::KeepAspectRatio));
|
|
|
|
} else {
|
|
|
|
m_resultImage = new QImage(m_inputImage.scaled(m_viewSize, Qt::KeepAspectRatio));
|
|
|
|
}
|
2018-03-13 06:39:36 +00:00
|
|
|
emit finished();
|
|
|
|
}
|