Compare commits

..

2 Commits

Author SHA1 Message Date
nou 9e79133464 Fix compile error 2025-11-01 12:11:53 +01:00
nou e08107aa13 Improve Save as 2025-11-01 12:06:24 +01:00
8 changed files with 60 additions and 21 deletions
+9
View File
@@ -59,6 +59,15 @@
</screenshots> </screenshots>
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<releases> <releases>
<release version="20251101" date="2025-11-01">
<description>
<ul>
<li>Better image Save as</li>
<li>Fix xisf file corruption when platesolving</li>
<li>Add selecting language</li>
</ul>
</description>
</release>
<release version="20250915" date="2025-09-15"> <release version="20250915" date="2025-09-15">
<description> <description>
<ul> <ul>
+5 -1
View File
@@ -193,7 +193,11 @@ void ConvertRunable::run()
QFileInfo info(m_outfile); QFileInfo info(m_outfile);
info.dir().mkpath("."); info.dir().mkpath(".");
if(m_params.autostretch) if(m_params.stretch)
{
rawimage->applySTF(m_params.mtf);
}
else if(m_params.autostretch)
{ {
rawimage->calcStats(); rawimage->calcStats();
MTFParam mtfParam = rawimage->calcMTFParams(); MTFParam mtfParam = rawimage->calcMTFParams();
+3
View File
@@ -6,6 +6,7 @@
#include <QSemaphore> #include <QSemaphore>
#include <QSize> #include <QSize>
#include "imageinfodata.h" #include "imageinfodata.h"
#include "mtfparam.h"
class Image; class Image;
@@ -33,6 +34,8 @@ public:
QSize resize; QSize resize;
Qt::AspectRatioMode aspect = Qt::KeepAspectRatio; Qt::AspectRatioMode aspect = Qt::KeepAspectRatio;
bool autostretch = false; bool autostretch = false;
bool stretch = false;
MTFParam mtf;
ConvertParams(){} ConvertParams(){}
ConvertParams(const QVariantMap &map); ConvertParams(const QVariantMap &map);
}; };
+14 -13
View File
@@ -620,9 +620,13 @@ void MainWindow::reindex()
void MainWindow::saveAs() void MainWindow::saveAs()
{ {
QString selectedFilter; QString selectedFilter;
ImagePtr ptr = m_ringList->currentImage();
if(!ptr)return;
QFileInfo srcFile(ptr->name());
QString file = QFileDialog::getSaveFileName(this, QString file = QFileDialog::getSaveFileName(this,
tr("Save as"), tr("Save as"),
_lastDir, _lastDir + "/" + srcFile.baseName(),
_saveFilter, _saveFilter,
&selectedFilter); &selectedFilter);
auto filterToFormat = [](const QString &file, const QString &filter) -> const QString auto filterToFormat = [](const QString &file, const QString &filter) -> const QString
@@ -644,25 +648,22 @@ void MainWindow::saveAs()
if(!file.isEmpty()) if(!file.isEmpty())
{ {
auto button = QMessageBox::question(this, tr("Apply stretch?"), tr("Apply current stretch function to image?"));
QString format = filterToFormat(file, selectedFilter); QString format = filterToFormat(file, selectedFilter);
if(format == "fits" || format == "xisf") convert(file, format, button == QMessageBox::Yes);
{
convert(file, format);
}
else
{
QImage img = m_image->renderToImage();
if(!img.isNull())
img.save(file, filterToFormat(file, selectedFilter).toLatin1().data());
}
} }
} }
void MainWindow::convert(const QString &outfile, const QString &format) void MainWindow::convert(const QString &outfile, const QString &format, bool stretch)
{ {
QString file = m_ringList->currentImage()->name(); QString file = m_ringList->currentImage()->name();
QThreadPool::globalInstance()->start(new ConvertRunable(file, outfile, format)); ConvertRunable::ConvertParams param;
param.stretch = stretch;
param.mtf = m_stretchPanel->params();
QThreadPool::globalInstance()->start(new ConvertRunable(file, outfile, format, param));
} }
void MainWindow::markImage() void MainWindow::markImage()
+1 -1
View File
@@ -52,7 +52,7 @@ public slots:
void indexDir(const QString &dir); void indexDir(const QString &dir);
void reindex(); void reindex();
void saveAs(); void saveAs();
void convert(const QString &outfile, const QString &format); void convert(const QString &outfile, const QString &format, bool stretch);
void markImage(); void markImage();
void unmarkImage(); void unmarkImage();
void markAndNext(); void markAndNext();
+22 -6
View File
@@ -1195,12 +1195,28 @@ void RawImage::applySTF(const MTFParam &mtfParams)
for(size_t i = 0; i < len; i++) for(size_t i = 0; i < len; i++)
{ {
float x; float x;
if constexpr(std::numeric_limits<std::remove_reference_t<decltype(*src)>>::is_integer)x = src[i] * iscale; if(m_ch == 4)
else x = src[i] * unit.first + unit.second; {
x = (x - mtfParams.blackPoint[0]) / (mtfParams.whitePoint[0] - mtfParams.blackPoint[0]); size_t c = i & 0x3;
x = std::clamp(x, 0.0f, 1.0f); if(c < 3)
x = ((mtfParams.midPoint[0] - 1.0f) * x) / ((2.0f * mtfParams.midPoint[0] - 1.0f) * x - mtfParams.midPoint[0]); {
src[i] = x * s; if constexpr(std::numeric_limits<std::remove_reference_t<decltype(*src)>>::is_integer)x = src[i] * iscale;
else x = src[i] * unit.first + unit.second;
x = (x - mtfParams.blackPoint[c]) / (mtfParams.whitePoint[c] - mtfParams.blackPoint[c]);
x = std::clamp(x, 0.0f, 1.0f);
x = ((mtfParams.midPoint[c] - 1.0f) * x) / ((2.0f * mtfParams.midPoint[c] - 1.0f) * x - mtfParams.midPoint[c]);
src[i] = x * s;
}
}
else
{
if constexpr(std::numeric_limits<std::remove_reference_t<decltype(*src)>>::is_integer)x = src[i] * iscale;
else x = src[i] * unit.first + unit.second;
x = (x - mtfParams.blackPoint[0]) / (mtfParams.whitePoint[0] - mtfParams.blackPoint[0]);
x = std::clamp(x, 0.0f, 1.0f);
x = ((mtfParams.midPoint[0] - 1.0f) * x) / ((2.0f * mtfParams.midPoint[0] - 1.0f) * x - mtfParams.midPoint[0]);
src[i] = x * s;
}
} }
}; };
+5
View File
@@ -104,6 +104,11 @@ StretchToolbar::~StretchToolbar()
settings.setValue("stretchtoolbar/autostretch", m_autoStretchOnLoad->isChecked()); settings.setValue("stretchtoolbar/autostretch", m_autoStretchOnLoad->isChecked());
} }
const MTFParam &StretchToolbar::params() const
{
return m_mtfParam;
}
void StretchToolbar::stretchImage(Image *img) void StretchToolbar::stretchImage(Image *img)
{ {
if(img && img->rawImage()) if(img && img->rawImage())
+1
View File
@@ -22,6 +22,7 @@ class StretchToolbar : public QToolBar
public: public:
explicit StretchToolbar(QWidget *parent = nullptr); explicit StretchToolbar(QWidget *parent = nullptr);
~StretchToolbar(); ~StretchToolbar();
const MTFParam& params() const;
public slots: public slots:
void stretchImage(Image *img); void stretchImage(Image *img);
void resetMTF(); void resetMTF();