mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fix adjustments calculation
This commit is contained in:
parent
4bef160b15
commit
926441549e
@ -8,4 +8,4 @@
|
||||
#define QSTRING_CSTR(str) str.toUtf8().constData()
|
||||
typedef QList< int > QIntList;
|
||||
|
||||
constexpr uint32_t UINT8_MAX_SQUARED = static_cast<uint32_t>(UINT8_MAX) * UINT8_MAX;
|
||||
constexpr double DOUBLE_MAX_SQUARED = static_cast<double>(std::numeric_limits<unsigned char>::max()) * std::numeric_limits<unsigned char>::max();
|
||||
|
@ -125,14 +125,14 @@ void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
||||
uint32_t nr_g = static_cast<uint32_t>((UINT8_MAX - ored) * ogreen);
|
||||
uint32_t r_g = static_cast<uint32_t>(ored * ogreen);
|
||||
|
||||
uint8_t black = static_cast<uint8_t>(nr_ng * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t red = static_cast<uint8_t>(r_ng * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t green = static_cast<uint8_t>(nr_g * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t blue = static_cast<uint8_t>(nr_ng * (oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t cyan = static_cast<uint8_t>(nr_g * (oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t magenta = static_cast<uint8_t>(r_ng * (oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t yellow = static_cast<uint8_t>(r_g * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t white = static_cast<uint8_t>(r_g * (oblue) / UINT8_MAX_SQUARED);
|
||||
uint8_t black = static_cast<uint8_t>(nr_ng * (UINT8_MAX - oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t red = static_cast<uint8_t>(r_ng * (UINT8_MAX - oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t green = static_cast<uint8_t>(nr_g * (UINT8_MAX - oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t blue = static_cast<uint8_t>(nr_ng * (oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t cyan = static_cast<uint8_t>(nr_g * (oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t magenta = static_cast<uint8_t>(r_ng * (oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t yellow = static_cast<uint8_t>(r_g * (UINT8_MAX - oblue) / DOUBLE_MAX_SQUARED);
|
||||
uint8_t white = static_cast<uint8_t>(r_g * (oblue) / DOUBLE_MAX_SQUARED);
|
||||
|
||||
uint8_t OR, OG, OB; // Original Colors
|
||||
uint8_t RR, RG, RB; // Red Adjustments
|
||||
|
@ -61,10 +61,10 @@ void RgbChannelAdjustment::apply(uint8_t input, uint8_t brightness, uint8_t & re
|
||||
|
||||
if (!_initialized[input])
|
||||
{
|
||||
const int adjustedInput = static_cast<int>(_brightness * input / UINT8_MAX_SQUARED);
|
||||
_mapping.red[input] = static_cast<quint8>(qBound(0, _adjust.red * adjustedInput, static_cast<int>(UINT8_MAX)));
|
||||
_mapping.green[input] = static_cast<quint8>(qBound(0 ,_adjust.green * adjustedInput, static_cast<int>(UINT8_MAX)));
|
||||
_mapping.blue[input] = static_cast<quint8>(qBound(0, _adjust.blue * adjustedInput, static_cast<int>(UINT8_MAX)));
|
||||
const double adjustedInput = _brightness * input / DOUBLE_MAX_SQUARED;
|
||||
_mapping.red[input] = static_cast<quint8>(qBound(0, static_cast<int>(_adjust.red * adjustedInput), static_cast<int>(UINT8_MAX)));
|
||||
_mapping.green[input] = static_cast<quint8>(qBound(0 ,static_cast<int>(_adjust.green * adjustedInput), static_cast<int>(UINT8_MAX)));
|
||||
_mapping.blue[input] = static_cast<quint8>(qBound(0, static_cast<int>(_adjust.blue * adjustedInput), static_cast<int>(UINT8_MAX)));
|
||||
_initialized[input] = true;
|
||||
}
|
||||
red = _mapping.red[input];
|
||||
|
Loading…
x
Reference in New Issue
Block a user