Integrate color temperature into RGB transformations

This commit is contained in:
LordGrey
2024-05-30 19:11:51 +02:00
parent 07dfce68f6
commit 5897e24316
17 changed files with 177 additions and 654 deletions

View File

@@ -598,16 +598,8 @@ void JsonAPI::handleAdjustmentCommand(const QJsonObject &message, const JsonApiC
return;
}
ColorCorrection *temperatureColorCorrection = _hyperion->getTemperature(adjustmentId);
if (temperatureColorCorrection == nullptr) {
Warning(_log, "Incorrect temperature adjustment identifier: %s", adjustmentId.toStdString().c_str());
return;
}
applyColorAdjustments(adjustment, colorAdjustment);
applyTransforms(adjustment, colorAdjustment);
applyTemperatureAdjustment(adjustment, temperatureColorCorrection);
_hyperion->adjustmentsUpdated();
sendSuccessReply(cmd);
}
@@ -644,6 +636,7 @@ void JsonAPI::applyTransforms(const QJsonObject &adjustment, ColorAdjustment *co
applyTransform("backlightColored", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBacklightColored);
applyTransform("brightness", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightness);
applyTransform("brightnessCompensation", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightnessCompensation);
applyTransform("temperature", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setTemperature);
applyTransform("saturationGain", adjustment, colorAdjustment->_okhsvTransform, &OkhsvTransform::setSaturationGain);
applyTransform("brightnessGain", adjustment, colorAdjustment->_okhsvTransform, &OkhsvTransform::setBrightnessGain);
}
@@ -673,6 +666,14 @@ void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &ad
}
}
template<typename T>
void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(int))
{
if (adjustment.contains(transformName)) {
(transform.*setFunction)(adjustment[transformName].toInt());
}
}
template<typename T>
void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(uint8_t))
{
@@ -681,19 +682,6 @@ void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &ad
}
}
void JsonAPI::applyTemperatureAdjustment(const QJsonObject &adjustment, ColorCorrection *colorCorrection)
{
if (adjustment.contains("temperature"))
{
int temperature = adjustment["temperature"].toInt(6500);
ColorRgb rgb = getRgbFromTemperature(temperature);
colorCorrection->_rgbCorrection.setcorrectionR(rgb.red);
colorCorrection->_rgbCorrection.setcorrectionG(rgb.green);
colorCorrection->_rgbCorrection.setcorrectionB(rgb.blue);
}
}
void JsonAPI::handleSourceSelectCommand(const QJsonObject &message, const JsonApiCommand& cmd)
{
if (message.contains("auto"))

View File

@@ -83,15 +83,7 @@ QJsonArray JsonInfo::getAdjustmentInfo(const Hyperion* hyperion, Logger* log)
adjustment["saturationGain"] = colorAdjustment->_okhsvTransform.getSaturationGain();
adjustment["brightnessGain"] = colorAdjustment->_okhsvTransform.getBrightnessGain();
ColorCorrection *temperatureColorCorrection = hyperion->getTemperature(adjustmentId);
if (temperatureColorCorrection == nullptr) {
Error(log, "Incorrect temperature adjustment id: %s", QSTRING_CSTR(adjustmentId));
continue;
}
// TODO: Return current Temperature in Kelvin
adjustment["temperature"] = 6600;
adjustment["temperature"] = colorAdjustment->_rgbTransform.getTemperature();
adjustmentArray.append(adjustment);
}