diff --git a/CMakeLists.txt b/CMakeLists.txt index f0ed799..abec9b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ set(TENMON_SRC main.cpp mainwindow.cpp mainwindow.h markedfiles.cpp markedfiles.h + mtfparam.h rawimage.cpp rawimage.h rawimage_sse.cpp scriptengine.cpp scriptengine.h diff --git a/imagewidget.cpp b/imagewidget.cpp index 0a5ab5a..6f2e6ea 100644 --- a/imagewidget.cpp +++ b/imagewidget.cpp @@ -359,7 +359,7 @@ void swPaint(std::shared_ptr &rawImage, float dx, float dy, float scal auto mtf = [&mtfParams](int i, float x) { x = (x - mtfParams.blackPoint[i]) / (mtfParams.whitePoint[i] - mtfParams.blackPoint[i]); - x = std::min(std::max(x, 0.0f), 1.0f); + x = std::clamp(x, 0.0f, 1.0f); return ((mtfParams.midPoint[i] - 1.0f) * x) / ((2.0f * mtfParams.midPoint[i] - 1.0f) * x - mtfParams.midPoint[i]); }; diff --git a/mtfparam.h b/mtfparam.h new file mode 100644 index 0000000..64c31e7 --- /dev/null +++ b/mtfparam.h @@ -0,0 +1,11 @@ +#ifndef MTFPARAM_H +#define MTFPARAM_H + +struct MTFParam +{ + float blackPoint[3] = {0.0f, 0.0f, 0.0f}; + float midPoint[3] = {0.5f, 0.5f, 0.5f}; + float whitePoint[3] = {1.0f, 1.0f, 1.0f}; +}; + +#endif // MTFPARAM_H diff --git a/stretchtoolbar.h b/stretchtoolbar.h index 60693e0..d4306bd 100644 --- a/stretchtoolbar.h +++ b/stretchtoolbar.h @@ -4,16 +4,10 @@ #include #include #include "stfslider.h" +#include "mtfparam.h" class Image; -struct MTFParam -{ - float blackPoint[3] = {0.0f, 0.0f, 0.0f}; - float midPoint[3] = {0.5f, 0.5f, 0.5f}; - float whitePoint[3] = {1.0f, 1.0f, 1.0f}; -}; - class StretchToolbar : public QToolBar { Q_OBJECT