diff --git a/include/utils/KelvinToRgb.h b/include/utils/KelvinToRgb.h index 7bd4d162..1f05d405 100644 --- a/include/utils/KelvinToRgb.h +++ b/include/utils/KelvinToRgb.h @@ -66,9 +66,9 @@ static ColorRgb getRgbFromTemperature(int temperature) } return { - static_cast(qBound(0, red, UINT8_MAX)), - static_cast(qBound(0, green, UINT8_MAX)), - static_cast(qBound(0, blue, UINT8_MAX)), + static_cast(qBound(0, red, static_cast(UINT8_MAX))), + static_cast(qBound(0, green, static_cast(UINT8_MAX))), + static_cast(qBound(0, blue, static_cast(UINT8_MAX))), }; } diff --git a/include/utils/global_defines.h b/include/utils/global_defines.h index 08c4a79a..a79e7ea0 100644 --- a/include/utils/global_defines.h +++ b/include/utils/global_defines.h @@ -1,8 +1,31 @@ #pragma once +#include +#include + +#include + #define QSTRING_CSTR(str) str.toUtf8().constData() typedef QList< int > QIntList; +// Undefine the max macro if it's defined (Windows-specific) +#ifdef max +#undef max +#endif + +// Define your constexpr variable constexpr uint32_t UINT8_MAX_SQUARED = static_cast(std::numeric_limits::max()) * static_cast(std::numeric_limits::max()); +// Restore the max macro only if it was previously defined (Windows-specific) +#ifdef _MSC_VER +#define NOMINMAX // Prevent Windows.h from defining min and max macros +#endif + +// Restore the max macro if needed (Windows-specific) +#ifdef _MSC_VER +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#endif + diff --git a/libsrc/utils/RgbChannelAdjustment.cpp b/libsrc/utils/RgbChannelAdjustment.cpp index fa899f72..8b222832 100644 --- a/libsrc/utils/RgbChannelAdjustment.cpp +++ b/libsrc/utils/RgbChannelAdjustment.cpp @@ -62,9 +62,9 @@ void RgbChannelAdjustment::apply(uint8_t input, uint8_t brightness, uint8_t & re if (!_initialized[input]) { const int adjustedInput = static_cast(_brightness * input / UINT8_MAX_SQUARED); - _mapping.red[input] = static_cast(qBound(0, _adjust.red * adjustedInput, UINT8_MAX)); - _mapping.green[input] = static_cast(qBound(0 ,_adjust.green * adjustedInput, UINT8_MAX)); - _mapping.blue[input] = static_cast(qBound(0, _adjust.blue * adjustedInput, UINT8_MAX)); + _mapping.red[input] = static_cast(qBound(0, _adjust.red * adjustedInput, static_cast(UINT8_MAX))); + _mapping.green[input] = static_cast(qBound(0 ,_adjust.green * adjustedInput, static_cast(UINT8_MAX))); + _mapping.blue[input] = static_cast(qBound(0, _adjust.blue * adjustedInput, static_cast(UINT8_MAX))); _initialized[input] = true; } red = _mapping.red[input];