mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Integrate color temperature into RGB transformations
This commit is contained in:
parent
07dfce68f6
commit
5897e24316
@ -277,11 +277,9 @@ private:
|
|||||||
///
|
///
|
||||||
void handleSystemCommand(const QJsonObject &message, const JsonApiCommand& cmd);
|
void handleSystemCommand(const QJsonObject &message, const JsonApiCommand& cmd);
|
||||||
|
|
||||||
|
|
||||||
void applyColorAdjustments(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
void applyColorAdjustments(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
||||||
void applyColorAdjustment(const QString &colorName, const QJsonObject &adjustment, RgbChannelAdjustment &rgbAdjustment);
|
void applyColorAdjustment(const QString &colorName, const QJsonObject &adjustment, RgbChannelAdjustment &rgbAdjustment);
|
||||||
void applyGammaTransform(const QString &transformName, const QJsonObject &adjustment, RgbTransform &rgbTransform, char channel);
|
void applyGammaTransform(const QString &transformName, const QJsonObject &adjustment, RgbTransform &rgbTransform, char channel);
|
||||||
void applyTemperatureAdjustment(const QJsonObject &adjustment, ColorCorrection *colorCorrection);
|
|
||||||
|
|
||||||
void applyTransforms(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
void applyTransforms(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -289,6 +287,8 @@ private:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(double));
|
void applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(double));
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
void applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(int));
|
||||||
|
template<typename T>
|
||||||
void applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(uint8_t));
|
void applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(uint8_t));
|
||||||
|
|
||||||
void handleTokenRequired(const JsonApiCommand& cmd);
|
void handleTokenRequired(const JsonApiCommand& cmd);
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
// Utils includes
|
|
||||||
#include <utils/RgbChannelCorrection.h>
|
|
||||||
|
|
||||||
class ColorCorrection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Unique identifier for this color correction
|
|
||||||
QString _id;
|
|
||||||
|
|
||||||
/// The RGB correction
|
|
||||||
RgbChannelCorrection _rgbCorrection;
|
|
||||||
};
|
|
@ -22,7 +22,6 @@
|
|||||||
#include <hyperion/LedString.h>
|
#include <hyperion/LedString.h>
|
||||||
#include <hyperion/PriorityMuxer.h>
|
#include <hyperion/PriorityMuxer.h>
|
||||||
#include <hyperion/ColorAdjustment.h>
|
#include <hyperion/ColorAdjustment.h>
|
||||||
#include <hyperion/ColorCorrection.h>
|
|
||||||
#include <hyperion/ComponentRegister.h>
|
#include <hyperion/ComponentRegister.h>
|
||||||
|
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
@ -184,30 +183,15 @@ public slots:
|
|||||||
///
|
///
|
||||||
QStringList getAdjustmentIds() const;
|
QStringList getAdjustmentIds() const;
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the list with unique correction identifiers
|
|
||||||
/// @return The list with correction identifiers
|
|
||||||
///
|
|
||||||
QStringList getTemperatureIds() const;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the ColorAdjustment with the given identifier
|
/// Returns the ColorAdjustment with the given identifier
|
||||||
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
|
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
|
||||||
///
|
///
|
||||||
ColorAdjustment * getAdjustment(const QString& id) const;
|
ColorAdjustment * getAdjustment(const QString& id) const;
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the ColorCorrection with the given identifier
|
|
||||||
/// @return The correction with the given identifier (or nullptr if the identifier does not exist)
|
|
||||||
///
|
|
||||||
ColorCorrection * getTemperature(const QString& id) const;
|
|
||||||
|
|
||||||
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||||
void adjustmentsUpdated();
|
void adjustmentsUpdated();
|
||||||
|
|
||||||
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
|
||||||
void temperaturesUpdated();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
|
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
|
||||||
/// lower priority channel (or off if no more channels are set)
|
/// lower priority channel (or off if no more channels are set)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void addAdjustment(ColorAdjustment * adjustment);
|
void addAdjustment(ColorAdjustment * adjustment);
|
||||||
|
|
||||||
void setAdjustmentForLed(const QString& id, int startLed, int endLed);
|
void setAdjustmentForLed(const QString& adjutmentId, int startLed, int endLed);
|
||||||
|
|
||||||
bool verifyAdjustments() const;
|
bool verifyAdjustments() const;
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ public:
|
|||||||
///
|
///
|
||||||
/// Returns the pointer to the ColorAdjustment with the given id
|
/// Returns the pointer to the ColorAdjustment with the given id
|
||||||
///
|
///
|
||||||
/// @param id The identifier of the ColorAdjustment
|
/// @param adjutmentId The identifier of the ColorAdjustment
|
||||||
///
|
///
|
||||||
/// @return The ColorAdjustment with the given id (or nullptr if it does not exist)
|
/// @return The ColorAdjustment with the given id (or nullptr if it does not exist)
|
||||||
///
|
///
|
||||||
ColorAdjustment* getAdjustment(const QString& id);
|
ColorAdjustment* getAdjustment(const QString& adjutmentId);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Performs the color adjustment from raw-color to led-color
|
/// Performs the color adjustment from raw-color to led-color
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// STL includes
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// Utils includes
|
|
||||||
#include <utils/ColorRgb.h>
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
|
|
||||||
// Hyperion includes
|
|
||||||
#include <hyperion/ColorCorrection.h>
|
|
||||||
|
|
||||||
///
|
|
||||||
/// The LedColorCorrection is responsible for performing color correction from 'raw' colors
|
|
||||||
/// received as input to colors mapped to match the color-properties of the leds.
|
|
||||||
///
|
|
||||||
class MultiColorCorrection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MultiColorCorrection(int ledCnt);
|
|
||||||
~MultiColorCorrection();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a new ColorCorrection to this MultiColorCorrection
|
|
||||||
*
|
|
||||||
* @param Correction The new ColorCorrection (ownership is transfered)
|
|
||||||
*/
|
|
||||||
void addCorrection(ColorCorrection * correction);
|
|
||||||
|
|
||||||
void setCorrectionForLed(const QString& id, int startLed, int endLed);
|
|
||||||
|
|
||||||
bool verifyCorrections() const;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the identifier of all the unique ColorCorrection
|
|
||||||
///
|
|
||||||
/// @return The list with unique id's of the ColorCorrections
|
|
||||||
QStringList & getCorrectionIds();
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the pointer to the ColorCorrection with the given id
|
|
||||||
///
|
|
||||||
/// @param id The identifier of the ColorCorrection
|
|
||||||
///
|
|
||||||
/// @return The ColorCorrection with the given id (or nullptr if it does not exist)
|
|
||||||
///
|
|
||||||
ColorCorrection* getCorrection(const QString& id);
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Performs the color transoformation from raw-color to led-color
|
|
||||||
///
|
|
||||||
/// @param ledColors The list with raw colors
|
|
||||||
///
|
|
||||||
void applyCorrection(std::vector<ColorRgb>& ledColors);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// List with Correction ids
|
|
||||||
QStringList _correctionIds;
|
|
||||||
|
|
||||||
/// List with unique ColorCorrections
|
|
||||||
std::vector<ColorCorrection*> _correction;
|
|
||||||
|
|
||||||
/// List with a pointer to the ColorCorrection for each individual led
|
|
||||||
std::vector<ColorCorrection*> _ledCorrections;
|
|
||||||
|
|
||||||
// logger instance
|
|
||||||
Logger * _log;
|
|
||||||
};
|
|
@ -1,66 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// STL includes
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
/// Correction for a single color byte value
|
|
||||||
/// All configuration values are unsigned int and assume the color value to be between 0 and 255
|
|
||||||
class RgbChannelCorrection
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Default constructor
|
|
||||||
RgbChannelCorrection();
|
|
||||||
|
|
||||||
/// Constructor
|
|
||||||
/// @param correctionR
|
|
||||||
/// @param correctionG
|
|
||||||
/// @param correctionB
|
|
||||||
|
|
||||||
RgbChannelCorrection(int correctionR, int correctionG, int correctionB);
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
~RgbChannelCorrection();
|
|
||||||
|
|
||||||
/// @return The current correctionR value
|
|
||||||
uint8_t getcorrectionR() const;
|
|
||||||
|
|
||||||
/// @param threshold New correctionR value
|
|
||||||
void setcorrectionR(uint8_t correctionR);
|
|
||||||
|
|
||||||
/// @return The current correctionG value
|
|
||||||
uint8_t getcorrectionG() const;
|
|
||||||
|
|
||||||
/// @param gamma New correctionG value
|
|
||||||
void setcorrectionG(uint8_t correctionG);
|
|
||||||
|
|
||||||
/// @return The current correctionB value
|
|
||||||
uint8_t getcorrectionB() const;
|
|
||||||
|
|
||||||
/// @param blacklevel New correctionB value
|
|
||||||
void setcorrectionB(uint8_t correctionB);
|
|
||||||
|
|
||||||
/// Transform the given array value
|
|
||||||
/// @param input The input color bytes
|
|
||||||
/// @return The corrected byte value
|
|
||||||
uint8_t correctionR(uint8_t inputR) const;
|
|
||||||
uint8_t correctionG(uint8_t inputG) const;
|
|
||||||
uint8_t correctionB(uint8_t inputB) const;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// (re)-initilize the color mapping
|
|
||||||
void initializeMapping();
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// The correction of R channel
|
|
||||||
int _correctionR;
|
|
||||||
/// The correction of G channel
|
|
||||||
int _correctionG;
|
|
||||||
/// The correction of B channel
|
|
||||||
int _correctionB;
|
|
||||||
|
|
||||||
/// The mapping from input color to output color
|
|
||||||
int _mappingR[256];
|
|
||||||
int _mappingG[256];
|
|
||||||
int _mappingB[256];
|
|
||||||
};
|
|
@ -3,6 +3,8 @@
|
|||||||
// STL includes
|
// STL includes
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <utils/ColorRgb.h>
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color transformation to adjust the saturation and value of a RGB color value
|
/// Color transformation to adjust the saturation and value of a RGB color value
|
||||||
///
|
///
|
||||||
@ -23,8 +25,9 @@ public:
|
|||||||
/// @param backlightThreshold The used lower brightness
|
/// @param backlightThreshold The used lower brightness
|
||||||
/// @param backlightColored use color in backlight
|
/// @param backlightColored use color in backlight
|
||||||
/// @param brightnessHigh The used higher brightness
|
/// @param brightnessHigh The used higher brightness
|
||||||
|
/// @param temeprature The given color temperature (in Kelvin)
|
||||||
///
|
///
|
||||||
RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation);
|
RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation, int temperature);
|
||||||
|
|
||||||
/// @return The current red gamma value
|
/// @return The current red gamma value
|
||||||
double getGammaR() const;
|
double getGammaR() const;
|
||||||
@ -79,10 +82,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// @note The values are updated in place.
|
/// @note The values are updated in place.
|
||||||
///
|
///
|
||||||
void getBrightnessComponents(uint8_t & rgb, uint8_t & cmy, uint8_t & w) const;
|
void getBrightnessComponents(uint8_t & rgb, uint8_t & cmy, uint8_t & white) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Apply the transform the the given RGB values.
|
/// Apply Gamma the the given RGB values.
|
||||||
///
|
///
|
||||||
/// @param red The red color component
|
/// @param red The red color component
|
||||||
/// @param green The green color component
|
/// @param green The green color component
|
||||||
@ -90,7 +93,22 @@ public:
|
|||||||
///
|
///
|
||||||
/// @note The values are updated in place.
|
/// @note The values are updated in place.
|
||||||
///
|
///
|
||||||
void transform(uint8_t & red, uint8_t & green, uint8_t & blue);
|
void applyGamma(uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Apply Backlight the the given RGB values.
|
||||||
|
///
|
||||||
|
/// @param red The red color component
|
||||||
|
/// @param green The green color component
|
||||||
|
/// @param blue The blue color component
|
||||||
|
///
|
||||||
|
/// @note The values are updated in place.
|
||||||
|
///
|
||||||
|
void applyBacklight(uint8_t & red, uint8_t & green, uint8_t & blue) const;
|
||||||
|
|
||||||
|
int getTemperature() const;
|
||||||
|
void setTemperature(int temperature);
|
||||||
|
void applyTemperature(ColorRgb& color) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -103,8 +121,9 @@ private:
|
|||||||
/// @param backlightColored en/disable color in backlight
|
/// @param backlightColored en/disable color in backlight
|
||||||
/// @param brightness The used brightness
|
/// @param brightness The used brightness
|
||||||
/// @param brightnessCompensation The used brightness compensation
|
/// @param brightnessCompensation The used brightness compensation
|
||||||
|
/// @param temeprature apply the given color temperature (in Kelvin)
|
||||||
///
|
///
|
||||||
void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation);
|
void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation, int temperature);
|
||||||
|
|
||||||
/// (re)-initilize the color mapping
|
/// (re)-initilize the color mapping
|
||||||
void initializeMapping(); /// The saturation gain
|
void initializeMapping(); /// The saturation gain
|
||||||
@ -112,25 +131,28 @@ private:
|
|||||||
void updateBrightnessComponents();
|
void updateBrightnessComponents();
|
||||||
|
|
||||||
/// backlight variables
|
/// backlight variables
|
||||||
bool _backLightEnabled
|
bool _backLightEnabled;
|
||||||
, _backlightColored;
|
bool _backlightColored;
|
||||||
double _backlightThreshold
|
double _backlightThreshold;
|
||||||
, _sumBrightnessLow;
|
double _sumBrightnessLow;
|
||||||
|
|
||||||
/// gamma variables
|
/// gamma variables
|
||||||
double _gammaR
|
double _gammaR;
|
||||||
, _gammaG
|
double _gammaG;
|
||||||
, _gammaB;
|
double _gammaB;
|
||||||
|
|
||||||
/// The mapping from input color to output color
|
/// The mapping from input color to output color
|
||||||
uint8_t _mappingR[256]
|
uint8_t _mappingR[256];
|
||||||
, _mappingG[256]
|
uint8_t _mappingG[256];
|
||||||
, _mappingB[256];
|
uint8_t _mappingB[256];
|
||||||
|
|
||||||
/// brightness variables
|
/// brightness variables
|
||||||
uint8_t _brightness
|
uint8_t _brightness;
|
||||||
, _brightnessCompensation
|
uint8_t _brightnessCompensation;
|
||||||
, _brightness_rgb
|
uint8_t _brightness_rgb;
|
||||||
, _brightness_cmy
|
uint8_t _brightness_cmy;
|
||||||
, _brightness_w;
|
uint8_t _brightness_w;
|
||||||
|
|
||||||
|
int _temperature;
|
||||||
|
ColorRgb _temperatureRGB;
|
||||||
};
|
};
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
|
|
||||||
#include <hyperion/ColorAdjustment.h>
|
#include <hyperion/ColorAdjustment.h>
|
||||||
#include <hyperion/MultiColorAdjustment.h>
|
#include <hyperion/MultiColorAdjustment.h>
|
||||||
#include "hyperion/MultiColorCorrection.h"
|
|
||||||
#include <hyperion/LedString.h>
|
#include <hyperion/LedString.h>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <utils/KelvinToRgb.h>
|
|
||||||
|
|
||||||
// fg effect
|
// fg effect
|
||||||
#include <hyperion/Hyperion.h>
|
#include <hyperion/Hyperion.h>
|
||||||
@ -79,8 +77,9 @@ namespace hyperion {
|
|||||||
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
|
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
|
||||||
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
|
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
|
||||||
const double gammaB = colorConfig["gammaBlue"].toDouble(1.0);
|
const double gammaB = colorConfig["gammaBlue"].toDouble(1.0);
|
||||||
|
const int temperature = colorConfig["temperature"].toInt(6600);
|
||||||
|
|
||||||
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, static_cast<uint8_t>(brightness), static_cast<uint8_t>(brightnessComp));
|
return RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, static_cast<uint8_t>(brightness), static_cast<uint8_t>(brightnessComp), temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
|
static OkhsvTransform createOkhsvTransform(const QJsonObject& colorConfig)
|
||||||
@ -102,32 +101,6 @@ namespace hyperion {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RgbChannelCorrection* createRgbChannelCorrection(const QJsonObject& colorConfig)
|
|
||||||
{
|
|
||||||
int varR = colorConfig["red"].toInt(255);
|
|
||||||
int varG = colorConfig["green"].toInt(255);
|
|
||||||
int varB = colorConfig["blue"].toInt(255);
|
|
||||||
|
|
||||||
RgbChannelCorrection* correction = new RgbChannelCorrection(varR, varG, varB);
|
|
||||||
return correction;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorCorrection * createColorCorrection(const QJsonObject& correctionConfig)
|
|
||||||
{
|
|
||||||
const QString id = correctionConfig["id"].toString("default");
|
|
||||||
|
|
||||||
RgbChannelCorrection * rgbCorrection = createRgbChannelCorrection(correctionConfig);
|
|
||||||
|
|
||||||
ColorCorrection * correction = new ColorCorrection();
|
|
||||||
correction->_id = id;
|
|
||||||
correction->_rgbCorrection = *rgbCorrection;
|
|
||||||
|
|
||||||
// Cleanup the allocated individual transforms
|
|
||||||
delete rgbCorrection;
|
|
||||||
|
|
||||||
return correction;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
|
static ColorAdjustment* createColorAdjustment(const QJsonObject & adjustmentConfig)
|
||||||
{
|
{
|
||||||
const QString id = adjustmentConfig["id"].toString("default");
|
const QString id = adjustmentConfig["id"].toString("default");
|
||||||
@ -205,74 +178,6 @@ namespace hyperion {
|
|||||||
return adjustment;
|
return adjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MultiColorCorrection * createLedColorsTemperature(int ledCnt, const QJsonObject & colorConfig)
|
|
||||||
{
|
|
||||||
// Create the result, the corrections are added to this
|
|
||||||
MultiColorCorrection * correction = new MultiColorCorrection(ledCnt);
|
|
||||||
|
|
||||||
const QJsonValue adjustmentConfig = colorConfig["channelAdjustment"];
|
|
||||||
const QRegularExpression overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
|
|
||||||
|
|
||||||
const QJsonArray & adjustmentConfigArray = adjustmentConfig.toArray();
|
|
||||||
for (signed i = 0; i < adjustmentConfigArray.size(); ++i)
|
|
||||||
{
|
|
||||||
const QJsonObject & config = adjustmentConfigArray.at(i).toObject();
|
|
||||||
ColorAdjustment * colorAdjustment = createColorAdjustment(config);
|
|
||||||
|
|
||||||
int temperature = config["temperature"].toInt();
|
|
||||||
|
|
||||||
ColorRgb rgb = getRgbFromTemperature(temperature);
|
|
||||||
QJsonObject correctionConfig {
|
|
||||||
{"red", rgb.red},
|
|
||||||
{"green", rgb.green},
|
|
||||||
{"blue", rgb.blue}
|
|
||||||
};
|
|
||||||
|
|
||||||
ColorCorrection * colorCorrection = createColorCorrection(correctionConfig);
|
|
||||||
correction->addCorrection(colorCorrection);
|
|
||||||
|
|
||||||
const QString ledIndicesStr = config["leds"].toString("").trimmed();
|
|
||||||
if (ledIndicesStr.compare("*") == 0)
|
|
||||||
{
|
|
||||||
// Special case for indices '*' => all leds
|
|
||||||
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
|
||||||
Info(Logger::getInstance("HYPERION"), "ColorCorrection '%s' => [0-%d]", QSTRING_CSTR(colorCorrection->_id), ledCnt-1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!overallExp.match(ledIndicesStr).hasMatch())
|
|
||||||
{
|
|
||||||
Error(Logger::getInstance("HYPERION"), "Given led indices %d not correct format: %s", i, QSTRING_CSTR(ledIndicesStr));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream ss;
|
|
||||||
const QStringList ledIndexList = ledIndicesStr.split(",");
|
|
||||||
for (int i=0; i<ledIndexList.size(); ++i) {
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
ss << ", ";
|
|
||||||
}
|
|
||||||
if (ledIndexList[i].contains("-"))
|
|
||||||
{
|
|
||||||
QStringList ledIndices = ledIndexList[i].split("-");
|
|
||||||
int startInd = ledIndices[0].toInt();
|
|
||||||
int endInd = ledIndices[1].toInt();
|
|
||||||
correction->setCorrectionForLed(colorCorrection->_id, startInd, endInd);
|
|
||||||
ss << startInd << "-" << endInd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int index = ledIndexList[i].toInt();
|
|
||||||
correction->setCorrectionForLed(colorCorrection->_id, index, index);
|
|
||||||
ss << index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Info(Logger::getInstance("HYPERION"), "ColorCorrection '%s' => [%s]", QSTRING_CSTR(colorAdjustment->_id), ss.str().c_str());
|
|
||||||
}
|
|
||||||
return correction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the 'led-string' with the integration area definition per led and the color
|
* Construct the 'led-string' with the integration area definition per led and the color
|
||||||
* ordering of the RGB channels
|
* ordering of the RGB channels
|
||||||
|
@ -598,16 +598,8 @@ void JsonAPI::handleAdjustmentCommand(const QJsonObject &message, const JsonApiC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorCorrection *temperatureColorCorrection = _hyperion->getTemperature(adjustmentId);
|
|
||||||
if (temperatureColorCorrection == nullptr) {
|
|
||||||
Warning(_log, "Incorrect temperature adjustment identifier: %s", adjustmentId.toStdString().c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
applyColorAdjustments(adjustment, colorAdjustment);
|
applyColorAdjustments(adjustment, colorAdjustment);
|
||||||
applyTransforms(adjustment, colorAdjustment);
|
applyTransforms(adjustment, colorAdjustment);
|
||||||
applyTemperatureAdjustment(adjustment, temperatureColorCorrection);
|
|
||||||
_hyperion->adjustmentsUpdated();
|
_hyperion->adjustmentsUpdated();
|
||||||
sendSuccessReply(cmd);
|
sendSuccessReply(cmd);
|
||||||
}
|
}
|
||||||
@ -644,6 +636,7 @@ void JsonAPI::applyTransforms(const QJsonObject &adjustment, ColorAdjustment *co
|
|||||||
applyTransform("backlightColored", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBacklightColored);
|
applyTransform("backlightColored", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBacklightColored);
|
||||||
applyTransform("brightness", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightness);
|
applyTransform("brightness", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightness);
|
||||||
applyTransform("brightnessCompensation", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightnessCompensation);
|
applyTransform("brightnessCompensation", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setBrightnessCompensation);
|
||||||
|
applyTransform("temperature", adjustment, colorAdjustment->_rgbTransform, &RgbTransform::setTemperature);
|
||||||
applyTransform("saturationGain", adjustment, colorAdjustment->_okhsvTransform, &OkhsvTransform::setSaturationGain);
|
applyTransform("saturationGain", adjustment, colorAdjustment->_okhsvTransform, &OkhsvTransform::setSaturationGain);
|
||||||
applyTransform("brightnessGain", adjustment, colorAdjustment->_okhsvTransform, &OkhsvTransform::setBrightnessGain);
|
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>
|
template<typename T>
|
||||||
void JsonAPI::applyTransform(const QString &transformName, const QJsonObject &adjustment, T &transform, void (T::*setFunction)(uint8_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)
|
void JsonAPI::handleSourceSelectCommand(const QJsonObject &message, const JsonApiCommand& cmd)
|
||||||
{
|
{
|
||||||
if (message.contains("auto"))
|
if (message.contains("auto"))
|
||||||
|
@ -83,15 +83,7 @@ QJsonArray JsonInfo::getAdjustmentInfo(const Hyperion* hyperion, Logger* log)
|
|||||||
adjustment["saturationGain"] = colorAdjustment->_okhsvTransform.getSaturationGain();
|
adjustment["saturationGain"] = colorAdjustment->_okhsvTransform.getSaturationGain();
|
||||||
adjustment["brightnessGain"] = colorAdjustment->_okhsvTransform.getBrightnessGain();
|
adjustment["brightnessGain"] = colorAdjustment->_okhsvTransform.getBrightnessGain();
|
||||||
|
|
||||||
|
adjustment["temperature"] = colorAdjustment->_rgbTransform.getTemperature();
|
||||||
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;
|
|
||||||
|
|
||||||
adjustmentArray.append(adjustment);
|
adjustmentArray.append(adjustment);
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,6 @@ add_library(hyperion
|
|||||||
# Led Color Transform
|
# Led Color Transform
|
||||||
${CMAKE_SOURCE_DIR}/include/hyperion/MultiColorAdjustment.h
|
${CMAKE_SOURCE_DIR}/include/hyperion/MultiColorAdjustment.h
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/hyperion/MultiColorAdjustment.cpp
|
${CMAKE_SOURCE_DIR}/libsrc/hyperion/MultiColorAdjustment.cpp
|
||||||
${CMAKE_SOURCE_DIR}/include/hyperion/ColorCorrection.h
|
|
||||||
${CMAKE_SOURCE_DIR}/include/hyperion/MultiColorCorrection.h
|
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/hyperion/MultiColorCorrection.cpp
|
|
||||||
# Priority Muxer
|
# Priority Muxer
|
||||||
${CMAKE_SOURCE_DIR}/include/hyperion/PriorityMuxer.h
|
${CMAKE_SOURCE_DIR}/include/hyperion/PriorityMuxer.h
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/hyperion/PriorityMuxer.cpp
|
${CMAKE_SOURCE_DIR}/libsrc/hyperion/PriorityMuxer.cpp
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <leddevice/LedDeviceWrapper.h>
|
#include <leddevice/LedDeviceWrapper.h>
|
||||||
|
|
||||||
#include <hyperion/MultiColorAdjustment.h>
|
#include <hyperion/MultiColorAdjustment.h>
|
||||||
#include <hyperion/MultiColorCorrection.h>
|
|
||||||
#include <hyperion/LinearColorSmoothing.h>
|
#include <hyperion/LinearColorSmoothing.h>
|
||||||
|
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
@ -57,7 +56,6 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
|||||||
, _imageProcessor(nullptr)
|
, _imageProcessor(nullptr)
|
||||||
, _muxer(nullptr)
|
, _muxer(nullptr)
|
||||||
, _raw2ledAdjustment(hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
, _raw2ledAdjustment(hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
||||||
, _raw2ledTemperature(hyperion::createLedColorsTemperature(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
|
||||||
, _ledDeviceWrapper(nullptr)
|
, _ledDeviceWrapper(nullptr)
|
||||||
, _deviceSmooth(nullptr)
|
, _deviceSmooth(nullptr)
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
@ -102,11 +100,6 @@ void Hyperion::start()
|
|||||||
// get newVideoMode from HyperionIManager
|
// get newVideoMode from HyperionIManager
|
||||||
connect(this, &Hyperion::newVideoMode, this, &Hyperion::handleNewVideoMode);
|
connect(this, &Hyperion::newVideoMode, this, &Hyperion::handleNewVideoMode);
|
||||||
|
|
||||||
if (!_raw2ledTemperature->verifyCorrections())
|
|
||||||
{
|
|
||||||
Warning(_log, "Color temperature incorrectly set");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_raw2ledAdjustment->verifyAdjustments())
|
if (!_raw2ledAdjustment->verifyAdjustments())
|
||||||
{
|
{
|
||||||
Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!");
|
Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!");
|
||||||
@ -229,9 +222,6 @@ void Hyperion::freeObjects()
|
|||||||
|
|
||||||
delete _raw2ledAdjustment;
|
delete _raw2ledAdjustment;
|
||||||
|
|
||||||
// delete the color temperature correction
|
|
||||||
delete _raw2ledTemperature;
|
|
||||||
|
|
||||||
#if defined(ENABLE_FORWARDER)
|
#if defined(ENABLE_FORWARDER)
|
||||||
delete _messageForwarder;
|
delete _messageForwarder;
|
||||||
#endif
|
#endif
|
||||||
@ -257,15 +247,6 @@ void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& co
|
|||||||
{
|
{
|
||||||
Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!");
|
Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// change in color recreate ledTemperature
|
|
||||||
delete _raw2ledTemperature;
|
|
||||||
_raw2ledTemperature = hyperion::createLedColorsTemperature(static_cast<int>(_ledString.leds().size()), obj);
|
|
||||||
|
|
||||||
if (!_raw2ledTemperature->verifyCorrections())
|
|
||||||
{
|
|
||||||
Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(type == settings::LEDS)
|
else if(type == settings::LEDS)
|
||||||
{
|
{
|
||||||
@ -298,10 +279,6 @@ void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& co
|
|||||||
delete _raw2ledAdjustment;
|
delete _raw2ledAdjustment;
|
||||||
_raw2ledAdjustment = hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object());
|
_raw2ledAdjustment = hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object());
|
||||||
|
|
||||||
// change in leds recreate ledTemperature
|
|
||||||
delete _raw2ledTemperature;
|
|
||||||
_raw2ledTemperature = hyperion::createLedColorsTemperature(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object());
|
|
||||||
|
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
// start cached effects
|
// start cached effects
|
||||||
_effectEngine->startCachedEffects();
|
_effectEngine->startCachedEffects();
|
||||||
@ -517,33 +494,17 @@ QStringList Hyperion::getAdjustmentIds() const
|
|||||||
return _raw2ledAdjustment->getAdjustmentIds();
|
return _raw2ledAdjustment->getAdjustmentIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Hyperion::getTemperatureIds() const
|
|
||||||
{
|
|
||||||
return _raw2ledTemperature->getCorrectionIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorAdjustment * Hyperion::getAdjustment(const QString& id) const
|
ColorAdjustment * Hyperion::getAdjustment(const QString& id) const
|
||||||
{
|
{
|
||||||
return _raw2ledAdjustment->getAdjustment(id);
|
return _raw2ledAdjustment->getAdjustment(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorCorrection * Hyperion::getTemperature(const QString& id) const
|
|
||||||
{
|
|
||||||
return _raw2ledTemperature->getCorrection(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hyperion::adjustmentsUpdated()
|
void Hyperion::adjustmentsUpdated()
|
||||||
{
|
{
|
||||||
emit adjustmentChanged();
|
emit adjustmentChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hyperion::temperaturesUpdated()
|
|
||||||
{
|
|
||||||
emit adjustmentChanged();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Hyperion::clear(int priority, bool forceClearAll)
|
bool Hyperion::clear(int priority, bool forceClearAll)
|
||||||
{
|
{
|
||||||
bool isCleared = false;
|
bool isCleared = false;
|
||||||
@ -736,7 +697,6 @@ void Hyperion::update()
|
|||||||
emit rawLedColors(_ledBuffer);
|
emit rawLedColors(_ledBuffer);
|
||||||
|
|
||||||
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||||
_raw2ledTemperature->applyCorrection(_ledBuffer);
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ColorRgb& color : _ledBuffer)
|
for (ColorRgb& color : _ledBuffer)
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
|
|
||||||
#include <utils/Logger.h>
|
#include <utils/Logger.h>
|
||||||
#include <hyperion/MultiColorAdjustment.h>
|
#include <hyperion/MultiColorAdjustment.h>
|
||||||
|
|
||||||
|
constexpr uint32_t UINT8_MAX_SQUARED = static_cast<uint32_t>(std::numeric_limits<unsigned char>::max()) * static_cast<uint32_t>(std::numeric_limits<unsigned char>::max());
|
||||||
|
|
||||||
MultiColorAdjustment::MultiColorAdjustment(int ledCnt)
|
MultiColorAdjustment::MultiColorAdjustment(int ledCnt)
|
||||||
: _ledAdjustments(ledCnt, nullptr)
|
: _ledAdjustments(static_cast<size_t>(ledCnt), nullptr)
|
||||||
, _log(Logger::getInstance("ADJUSTMENT"))
|
, _log(Logger::getInstance("ADJUSTMENT"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiColorAdjustment::~MultiColorAdjustment()
|
MultiColorAdjustment::~MultiColorAdjustment()
|
||||||
{
|
{
|
||||||
// Clean up all the transforms
|
for (ColorAdjustment* adjustment : _adjustment)
|
||||||
for (ColorAdjustment * adjustment : _adjustment)
|
|
||||||
{
|
{
|
||||||
delete adjustment;
|
delete adjustment;
|
||||||
// BUG: Calling pop_back while iterating is invalid
|
|
||||||
_adjustment.pop_back();
|
|
||||||
}
|
}
|
||||||
|
_adjustment.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiColorAdjustment::addAdjustment(ColorAdjustment * adjustment)
|
void MultiColorAdjustment::addAdjustment(ColorAdjustment * adjustment)
|
||||||
@ -25,7 +29,7 @@ void MultiColorAdjustment::addAdjustment(ColorAdjustment * adjustment)
|
|||||||
_adjustment.push_back(adjustment);
|
_adjustment.push_back(adjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiColorAdjustment::setAdjustmentForLed(const QString& id, int startLed, int endLed)
|
void MultiColorAdjustment::setAdjustmentForLed(const QString& adjutmentId, int startLed, int endLed)
|
||||||
{
|
{
|
||||||
// abort
|
// abort
|
||||||
if(startLed > endLed)
|
if(startLed > endLed)
|
||||||
@ -41,8 +45,8 @@ void MultiColorAdjustment::setAdjustmentForLed(const QString& id, int startLed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the identified adjustment (don't care if is nullptr)
|
// Get the identified adjustment (don't care if is nullptr)
|
||||||
ColorAdjustment * adjustment = getAdjustment(id);
|
ColorAdjustment * adjustment = getAdjustment(adjutmentId);
|
||||||
for (int iLed=startLed; iLed<=endLed; ++iLed)
|
for (size_t iLed=static_cast<size_t>(startLed); iLed<=static_cast<size_t>(endLed); ++iLed)
|
||||||
{
|
{
|
||||||
_ledAdjustments[iLed] = adjustment;
|
_ledAdjustments[iLed] = adjustment;
|
||||||
}
|
}
|
||||||
@ -50,18 +54,18 @@ void MultiColorAdjustment::setAdjustmentForLed(const QString& id, int startLed,
|
|||||||
|
|
||||||
bool MultiColorAdjustment::verifyAdjustments() const
|
bool MultiColorAdjustment::verifyAdjustments() const
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool isAdjustmentDefined = true;
|
||||||
for (unsigned iLed=0; iLed<_ledAdjustments.size(); ++iLed)
|
for (unsigned iLed=0; iLed<_ledAdjustments.size(); ++iLed)
|
||||||
{
|
{
|
||||||
ColorAdjustment * adjustment = _ledAdjustments[iLed];
|
const ColorAdjustment * adjustment = _ledAdjustments[iLed];
|
||||||
|
|
||||||
if (adjustment == nullptr)
|
if (adjustment == nullptr)
|
||||||
{
|
{
|
||||||
Warning(_log, "No calibration set for led %d", iLed);
|
Warning(_log, "No calibration set for LED %d", iLed);
|
||||||
ok = false;
|
isAdjustmentDefined = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return isAdjustmentDefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MultiColorAdjustment::getAdjustmentIds() const
|
QStringList MultiColorAdjustment::getAdjustmentIds() const
|
||||||
@ -69,15 +73,14 @@ QStringList MultiColorAdjustment::getAdjustmentIds() const
|
|||||||
return _adjustmentIds;
|
return _adjustmentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorAdjustment* MultiColorAdjustment::getAdjustment(const QString& id)
|
ColorAdjustment* MultiColorAdjustment::getAdjustment(const QString& adjustmentId)
|
||||||
{
|
{
|
||||||
// Iterate through the unique adjustments until we find the one with the given id
|
auto adjustmentIter = std::find_if(_adjustment.begin(), _adjustment.end(), [&adjustmentId](const ColorAdjustment* adjustment) {
|
||||||
for (ColorAdjustment* adjustment : _adjustment)
|
return adjustment->_id == adjustmentId;
|
||||||
{
|
});
|
||||||
if (adjustment->_id == id)
|
|
||||||
{
|
if (adjustmentIter != _adjustment.end()) {
|
||||||
return adjustment;
|
return *adjustmentIter;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The ColorAdjustment was not found
|
// The ColorAdjustment was not found
|
||||||
@ -100,8 +103,7 @@ void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
|||||||
ColorAdjustment* adjustment = _ledAdjustments[i];
|
ColorAdjustment* adjustment = _ledAdjustments[i];
|
||||||
if (adjustment == nullptr)
|
if (adjustment == nullptr)
|
||||||
{
|
{
|
||||||
//std::cout << "MultiColorAdjustment::applyAdjustment() - No transform set for this led : " << i << std::endl;
|
// No transform set for this LED (do nothing)
|
||||||
// No transform set for this led (do nothing)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ColorRgb& color = ledColors[i];
|
ColorRgb& color = ledColors[i];
|
||||||
@ -117,27 +119,34 @@ void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
|||||||
{
|
{
|
||||||
adjustment->_okhsvTransform.transform(ored, ogreen, oblue);
|
adjustment->_okhsvTransform.transform(ored, ogreen, oblue);
|
||||||
}
|
}
|
||||||
adjustment->_rgbTransform.transform(ored,ogreen,oblue);
|
|
||||||
|
adjustment->_rgbTransform.applyGamma(ored,ogreen,oblue);
|
||||||
adjustment->_rgbTransform.getBrightnessComponents(B_RGB, B_CMY, B_W);
|
adjustment->_rgbTransform.getBrightnessComponents(B_RGB, B_CMY, B_W);
|
||||||
|
|
||||||
uint32_t nrng = (uint32_t) (255-ored)*(255-ogreen);
|
uint32_t nr_ng = static_cast<uint32_t>((UINT8_MAX - ored) * (UINT8_MAX - ogreen));
|
||||||
uint32_t rng = (uint32_t) (ored) *(255-ogreen);
|
uint32_t r_ng = static_cast<uint32_t>(ored * (UINT8_MAX - ogreen));
|
||||||
uint32_t nrg = (uint32_t) (255-ored)*(ogreen);
|
uint32_t nr_g = static_cast<uint32_t>((UINT8_MAX - ored) * ogreen);
|
||||||
uint32_t rg = (uint32_t) (ored) *(ogreen);
|
uint32_t r_g = static_cast<uint32_t>(ored * ogreen);
|
||||||
|
|
||||||
uint8_t black = nrng*(255-oblue)/65025;
|
uint8_t black = static_cast<uint8_t>(nr_ng * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t red = rng *(255-oblue)/65025;
|
uint8_t red = static_cast<uint8_t>(r_ng * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t green = nrg *(255-oblue)/65025;
|
uint8_t green = static_cast<uint8_t>(nr_g * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t blue = nrng*(oblue) /65025;
|
uint8_t blue = static_cast<uint8_t>(nr_ng * (oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t cyan = nrg *(oblue) /65025;
|
uint8_t cyan = static_cast<uint8_t>(nr_g * (oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t magenta = rng *(oblue) /65025;
|
uint8_t magenta = static_cast<uint8_t>(r_ng * (oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t yellow = rg *(255-oblue)/65025;
|
uint8_t yellow = static_cast<uint8_t>(r_g * (UINT8_MAX - oblue) / UINT8_MAX_SQUARED);
|
||||||
uint8_t white = rg *(oblue) /65025;
|
uint8_t white = static_cast<uint8_t>(r_g * (oblue) / UINT8_MAX_SQUARED);
|
||||||
|
|
||||||
uint8_t OR, OG, OB, RR, RG, RB, GR, GG, GB, BR, BG, BB;
|
uint8_t OR, OG, OB; // Original Colors
|
||||||
uint8_t CR, CG, CB, MR, MG, MB, YR, YG, YB, WR, WG, WB;
|
uint8_t RR, RG, RB; // Red Adjustments
|
||||||
|
uint8_t GR, GG, GB; // Green Adjustments
|
||||||
|
uint8_t BR, BG, BB; // Blue Adjustments
|
||||||
|
uint8_t CR, CG, CB; // Cyan Adjustments
|
||||||
|
uint8_t MR, MG, MB; // Magenta Adjustments
|
||||||
|
uint8_t YR, YG, YB; // Yellow Adjustments
|
||||||
|
uint8_t WR, WG, WB; // White Adjustments
|
||||||
|
|
||||||
adjustment->_rgbBlackAdjustment.apply (black , 255 , OR, OG, OB);
|
adjustment->_rgbBlackAdjustment.apply (black , UINT8_MAX, OR, OG, OB);
|
||||||
adjustment->_rgbRedAdjustment.apply (red , B_RGB, RR, RG, RB);
|
adjustment->_rgbRedAdjustment.apply (red , B_RGB, RR, RG, RB);
|
||||||
adjustment->_rgbGreenAdjustment.apply (green , B_RGB, GR, GG, GB);
|
adjustment->_rgbGreenAdjustment.apply (green , B_RGB, GR, GG, GB);
|
||||||
adjustment->_rgbBlueAdjustment.apply (blue , B_RGB, BR, BG, BB);
|
adjustment->_rgbBlueAdjustment.apply (blue , B_RGB, BR, BG, BB);
|
||||||
@ -149,5 +158,8 @@ void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
|||||||
color.red = OR + RR + GR + BR + CR + MR + YR + WR;
|
color.red = OR + RR + GR + BR + CR + MR + YR + WR;
|
||||||
color.green = OG + RG + GG + BG + CG + MG + YG + WG;
|
color.green = OG + RG + GG + BG + CG + MG + YG + WG;
|
||||||
color.blue = OB + RB + GB + BB + CB + MB + YB + WB;
|
color.blue = OB + RB + GB + BB + CB + MB + YB + WB;
|
||||||
|
|
||||||
|
adjustment->_rgbTransform.applyTemperature(color);
|
||||||
|
adjustment->_rgbTransform.applyBacklight(color.red, color.green, color.green);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
// Hyperion includes
|
|
||||||
#include <utils/Logger.h>
|
|
||||||
#include <hyperion/MultiColorCorrection.h>
|
|
||||||
|
|
||||||
MultiColorCorrection::MultiColorCorrection(int ledCnt) :
|
|
||||||
_ledCorrections(ledCnt, nullptr)
|
|
||||||
, _log(Logger::getInstance("CORRECTION"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiColorCorrection::~MultiColorCorrection()
|
|
||||||
{
|
|
||||||
// Clean up all the correctinos
|
|
||||||
for (ColorCorrection * correction : _correction)
|
|
||||||
{
|
|
||||||
delete correction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiColorCorrection::addCorrection(ColorCorrection * correction)
|
|
||||||
{
|
|
||||||
_correctionIds.push_back(correction->_id);
|
|
||||||
_correction.push_back(correction);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiColorCorrection::setCorrectionForLed(const QString& id, int startLed, int endLed)
|
|
||||||
{
|
|
||||||
// abort
|
|
||||||
if(startLed > endLed)
|
|
||||||
{
|
|
||||||
Error(_log,"startLed > endLed -> %d > %d", startLed, endLed);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// catch wrong values
|
|
||||||
if(endLed > static_cast<int>(_ledCorrections.size()-1))
|
|
||||||
{
|
|
||||||
Warning(_log,"The color correction 'LED index' field has LEDs specified which aren't part of your led layout");
|
|
||||||
endLed = static_cast<int>(_ledCorrections.size()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the identified correction (don't care if is nullptr)
|
|
||||||
ColorCorrection * correction = getCorrection(id);
|
|
||||||
for (int iLed=startLed; iLed<=endLed; ++iLed)
|
|
||||||
{
|
|
||||||
_ledCorrections[iLed] = correction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MultiColorCorrection::verifyCorrections() const
|
|
||||||
{
|
|
||||||
bool ok = true;
|
|
||||||
for (unsigned iLed=0; iLed<_ledCorrections.size(); ++iLed)
|
|
||||||
{
|
|
||||||
ColorCorrection* adjustment = _ledCorrections[iLed];
|
|
||||||
|
|
||||||
if (adjustment == nullptr)
|
|
||||||
{
|
|
||||||
Warning(_log, "No correction set for led %d", iLed);
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList & MultiColorCorrection::getCorrectionIds()
|
|
||||||
{
|
|
||||||
return _correctionIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorCorrection* MultiColorCorrection::getCorrection(const QString& id)
|
|
||||||
{
|
|
||||||
// Iterate through the unique corrections until we find the one with the given id
|
|
||||||
for (ColorCorrection * correction : _correction)
|
|
||||||
{
|
|
||||||
if (correction->_id == id)
|
|
||||||
{
|
|
||||||
return correction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The ColorCorrection was not found
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiColorCorrection::applyCorrection(std::vector<ColorRgb>& ledColors)
|
|
||||||
{
|
|
||||||
const size_t itCnt = qMin(_ledCorrections.size(), ledColors.size());
|
|
||||||
for (size_t i=0; i<itCnt; ++i)
|
|
||||||
{
|
|
||||||
ColorCorrection * correction = _ledCorrections[i];
|
|
||||||
if (correction == nullptr)
|
|
||||||
{
|
|
||||||
std::cout << "MultiColorCorrection::applyCorrection() - No correction set for this led : " << i << std::endl;
|
|
||||||
// No correction set for this led (do nothing)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ColorRgb& color = ledColors[i];
|
|
||||||
|
|
||||||
color.red = correction->_rgbCorrection.correctionR(color.red);
|
|
||||||
color.green = correction->_rgbCorrection.correctionG(color.green);
|
|
||||||
color.blue = correction->_rgbCorrection.correctionB(color.blue);
|
|
||||||
}
|
|
||||||
}
|
|
@ -57,8 +57,6 @@ add_library(hyperion-utils
|
|||||||
# Rgb single color adjustment/correction
|
# Rgb single color adjustment/correction
|
||||||
${CMAKE_SOURCE_DIR}/include/utils/RgbChannelAdjustment.h
|
${CMAKE_SOURCE_DIR}/include/utils/RgbChannelAdjustment.h
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/utils/RgbChannelAdjustment.cpp
|
${CMAKE_SOURCE_DIR}/libsrc/utils/RgbChannelAdjustment.cpp
|
||||||
${CMAKE_SOURCE_DIR}/include/utils/RgbChannelCorrection.h
|
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/utils/RgbChannelCorrection.cpp
|
|
||||||
# Color conversion/transformation
|
# Color conversion/transformation
|
||||||
${CMAKE_SOURCE_DIR}/include/utils/RgbToRgbw.h
|
${CMAKE_SOURCE_DIR}/include/utils/RgbToRgbw.h
|
||||||
${CMAKE_SOURCE_DIR}/libsrc/utils/RgbToRgbw.cpp
|
${CMAKE_SOURCE_DIR}/libsrc/utils/RgbToRgbw.cpp
|
||||||
|
@ -1,120 +0,0 @@
|
|||||||
// STL includes
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
// Utils includes
|
|
||||||
#include <utils/RgbChannelCorrection.h>
|
|
||||||
|
|
||||||
RgbChannelCorrection::RgbChannelCorrection() :
|
|
||||||
_correctionR(255),
|
|
||||||
_correctionG(255),
|
|
||||||
_correctionB(255)
|
|
||||||
{
|
|
||||||
initializeMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
RgbChannelCorrection::RgbChannelCorrection(int correctionR, int correctionG, int correctionB) :
|
|
||||||
_correctionR(correctionR),
|
|
||||||
_correctionG(correctionG),
|
|
||||||
_correctionB(correctionB)
|
|
||||||
{
|
|
||||||
initializeMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
RgbChannelCorrection::~RgbChannelCorrection()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::getcorrectionR() const
|
|
||||||
{
|
|
||||||
return _correctionR;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RgbChannelCorrection::setcorrectionR(uint8_t correctionR)
|
|
||||||
{
|
|
||||||
_correctionR = correctionR;
|
|
||||||
initializeMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::getcorrectionG() const
|
|
||||||
{
|
|
||||||
return _correctionG;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RgbChannelCorrection::setcorrectionG(uint8_t correctionG)
|
|
||||||
{
|
|
||||||
_correctionG = correctionG;
|
|
||||||
initializeMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::getcorrectionB() const
|
|
||||||
{
|
|
||||||
return _correctionB;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RgbChannelCorrection::setcorrectionB(uint8_t correctionB)
|
|
||||||
{
|
|
||||||
_correctionB = correctionB;
|
|
||||||
initializeMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::correctionR(uint8_t inputR) const
|
|
||||||
{
|
|
||||||
return _mappingR[inputR];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::correctionG(uint8_t inputG) const
|
|
||||||
{
|
|
||||||
return _mappingG[inputG];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t RgbChannelCorrection::correctionB(uint8_t inputB) const
|
|
||||||
{
|
|
||||||
return _mappingB[inputB];
|
|
||||||
}
|
|
||||||
|
|
||||||
void RgbChannelCorrection::initializeMapping()
|
|
||||||
{
|
|
||||||
// initialize the mapping
|
|
||||||
for (int i = 0; i < 256; ++i)
|
|
||||||
{
|
|
||||||
int outputR = (i * _correctionR) / 255;
|
|
||||||
if (outputR < -255)
|
|
||||||
{
|
|
||||||
outputR = -255;
|
|
||||||
}
|
|
||||||
else if (outputR > 255)
|
|
||||||
{
|
|
||||||
outputR = 255;
|
|
||||||
}
|
|
||||||
_mappingR[i] = outputR;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 256; ++i)
|
|
||||||
{
|
|
||||||
int outputG = (i * _correctionG) / 255;
|
|
||||||
if (outputG < -255)
|
|
||||||
{
|
|
||||||
outputG = -255;
|
|
||||||
}
|
|
||||||
else if (outputG > 255)
|
|
||||||
{
|
|
||||||
outputG = 255;
|
|
||||||
}
|
|
||||||
_mappingG[i] = outputG;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 256; ++i)
|
|
||||||
{
|
|
||||||
int outputB = (i * _correctionB) / 255;
|
|
||||||
if (outputB < -255)
|
|
||||||
{
|
|
||||||
outputB = -255;
|
|
||||||
}
|
|
||||||
else if (outputB > 255)
|
|
||||||
{
|
|
||||||
outputB = 255;
|
|
||||||
}
|
|
||||||
_mappingB[i] = outputB;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
|||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <utils/RgbTransform.h>
|
#include <utils/RgbTransform.h>
|
||||||
|
#include <utils/KelvinToRgb.h>
|
||||||
|
|
||||||
|
#include<QDebug>
|
||||||
|
|
||||||
RgbTransform::RgbTransform()
|
RgbTransform::RgbTransform()
|
||||||
: RgbTransform::RgbTransform(1.0, 1.0, 1.0, 0.0, false, 100, 100)
|
: RgbTransform::RgbTransform(1.0, 1.0, 1.0, 0.0, false, 100, 100, 6600)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RgbTransform::RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation)
|
RgbTransform::RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation, int temperature)
|
||||||
: _brightness(brightness)
|
: _brightness(brightness)
|
||||||
, _brightnessCompensation(brightnessCompensation)
|
, _brightnessCompensation(brightnessCompensation)
|
||||||
{
|
{
|
||||||
init(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, _brightness, _brightnessCompensation);
|
init(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, _brightness, _brightnessCompensation, temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RgbTransform::init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation)
|
void RgbTransform::init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation, int temperature)
|
||||||
{
|
{
|
||||||
_backLightEnabled = true;
|
_backLightEnabled = true;
|
||||||
setGamma(gammaR,gammaG,gammaB);
|
setGamma(gammaR,gammaG,gammaB);
|
||||||
@ -21,6 +24,7 @@ void RgbTransform::init(double gammaR, double gammaG, double gammaB, double back
|
|||||||
setBacklightColored(backlightColored);
|
setBacklightColored(backlightColored);
|
||||||
setBrightness(brightness);
|
setBrightness(brightness);
|
||||||
setBrightnessCompensation(brightnessCompensation);
|
setBrightnessCompensation(brightnessCompensation);
|
||||||
|
setTemperature(temperature);
|
||||||
initializeMapping();
|
initializeMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,18 +53,34 @@ void RgbTransform::setGamma(double gammaR, double gammaG, double gammaB)
|
|||||||
|
|
||||||
void RgbTransform::initializeMapping()
|
void RgbTransform::initializeMapping()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i <= UINT8_MAX; ++i)
|
||||||
{
|
{
|
||||||
_mappingR[i] = qMin(qMax((int)(qPow(i / 255.0, _gammaR) * 255), 0), 255);
|
// Calculate normalized value
|
||||||
_mappingG[i] = qMin(qMax((int)(qPow(i / 255.0, _gammaG) * 255), 0), 255);
|
double normalizedValueR = static_cast<double>(i) / UINT8_MAX;
|
||||||
_mappingB[i] = qMin(qMax((int)(qPow(i / 255.0, _gammaB) * 255), 0), 255);
|
double normalizedValueG = static_cast<double>(i) / UINT8_MAX;
|
||||||
|
double normalizedValueB = static_cast<double>(i) / UINT8_MAX;
|
||||||
|
|
||||||
|
// Apply gamma correction
|
||||||
|
double gammaCorrectedValueR = qPow(normalizedValueR, _gammaR) * UINT8_MAX;
|
||||||
|
double gammaCorrectedValueG = qPow(normalizedValueG, _gammaG) * UINT8_MAX;
|
||||||
|
double gammaCorrectedValueB = qPow(normalizedValueB, _gammaB) * UINT8_MAX;
|
||||||
|
|
||||||
|
// Clamp values to valid range [0, UINT8_MAX]
|
||||||
|
quint8 clampedValueR = static_cast<quint8>(qMin(qMax(gammaCorrectedValueR, 0.0), static_cast<double>(UINT8_MAX)));
|
||||||
|
quint8 clampedValueG = static_cast<quint8>(qMin(qMax(gammaCorrectedValueG, 0.0), static_cast<double>(UINT8_MAX)));
|
||||||
|
quint8 clampedValueB = static_cast<quint8>(qMin(qMax(gammaCorrectedValueB, 0.0), static_cast<double>(UINT8_MAX)));
|
||||||
|
|
||||||
|
// Assign clamped values to _mapping arrays
|
||||||
|
_mappingR[i] = clampedValueR;
|
||||||
|
_mappingG[i] = clampedValueG;
|
||||||
|
_mappingB[i] = clampedValueB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int RgbTransform::getBacklightThreshold() const
|
int RgbTransform::getBacklightThreshold() const
|
||||||
{
|
{
|
||||||
return _backlightThreshold;
|
return static_cast<int>(_backlightThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RgbTransform::setBacklightThreshold(double backlightThreshold)
|
void RgbTransform::setBacklightThreshold(double backlightThreshold)
|
||||||
@ -116,60 +136,81 @@ void RgbTransform::updateBrightnessComponents()
|
|||||||
double Fw = _brightnessCompensation*2.0/100.0+1.0;
|
double Fw = _brightnessCompensation*2.0/100.0+1.0;
|
||||||
double Fcmy = _brightnessCompensation/100.0+1.0;
|
double Fcmy = _brightnessCompensation/100.0+1.0;
|
||||||
|
|
||||||
double B_in= 0;
|
|
||||||
_brightness_rgb = 0;
|
_brightness_rgb = 0;
|
||||||
_brightness_cmy = 0;
|
_brightness_cmy = 0;
|
||||||
_brightness_w = 0;
|
_brightness_w = 0;
|
||||||
|
|
||||||
if (_brightness > 0)
|
if (_brightness > 0)
|
||||||
{
|
{
|
||||||
B_in = (_brightness<50)? -0.09*_brightness+7.5 : -0.04*_brightness+5.0;
|
double B_in = (_brightness < 50) ? -0.09 * _brightness + 7.5 : -0.04 * _brightness + 5.0;
|
||||||
|
|
||||||
_brightness_rgb = std::ceil(qMin(255.0,255.0/B_in));
|
// Ensure that the result is converted to an integer before assigning to uint8_t
|
||||||
_brightness_cmy = std::ceil(qMin(255.0,255.0/(B_in*Fcmy)));
|
_brightness_rgb = static_cast<uint8_t>(std::ceil(qMin(static_cast<double>(UINT8_MAX), UINT8_MAX / B_in)));
|
||||||
_brightness_w = std::ceil(qMin(255.0,255.0/(B_in*Fw)));
|
_brightness_cmy = static_cast<uint8_t>(std::ceil(qMin(static_cast<double>(UINT8_MAX), UINT8_MAX / (B_in * Fcmy))));
|
||||||
|
_brightness_w = static_cast<uint8_t>(std::ceil(qMin(static_cast<double>(UINT8_MAX), UINT8_MAX / (B_in * Fw))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RgbTransform::getBrightnessComponents(uint8_t & rgb, uint8_t & cmy, uint8_t & w) const
|
void RgbTransform::getBrightnessComponents(uint8_t & rgb, uint8_t & cmy, uint8_t & white) const
|
||||||
{
|
{
|
||||||
rgb = _brightness_rgb;
|
rgb = _brightness_rgb;
|
||||||
cmy = _brightness_cmy;
|
cmy = _brightness_cmy;
|
||||||
w = _brightness_w;
|
white = _brightness_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RgbTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue)
|
void RgbTransform::applyGamma(uint8_t & red, uint8_t & green, uint8_t & blue)
|
||||||
{
|
{
|
||||||
// apply gamma
|
// apply gamma
|
||||||
red = _mappingR[red];
|
red = _mappingR[red];
|
||||||
green = _mappingG[green];
|
green = _mappingG[green];
|
||||||
blue = _mappingB[blue];
|
blue = _mappingB[blue];
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbTransform::applyBacklight(uint8_t & red, uint8_t & green, uint8_t & blue) const
|
||||||
|
{
|
||||||
// apply brightnesss
|
// apply brightnesss
|
||||||
int rgbSum = red+green+blue;
|
int rgbSum = red+green+blue;
|
||||||
|
|
||||||
if ( _backLightEnabled && _sumBrightnessLow>0 && rgbSum < _sumBrightnessLow)
|
if ( _backLightEnabled && _sumBrightnessLow > 0 && rgbSum < _sumBrightnessLow)
|
||||||
{
|
{
|
||||||
if (_backlightColored)
|
if (_backlightColored)
|
||||||
{
|
{
|
||||||
if (rgbSum == 0)
|
if (rgbSum == 0)
|
||||||
{
|
{
|
||||||
if (red ==0) red = 1;
|
if (red ==0) { red = 1; }
|
||||||
if (green==0) green = 1;
|
if (green==0) { green = 1; }
|
||||||
if (blue ==0) blue = 1;
|
if (blue ==0) { blue = 1; }
|
||||||
rgbSum = red+green+blue;
|
rgbSum = red+green+blue;
|
||||||
}
|
}
|
||||||
double cL =qMin((int)(_sumBrightnessLow /rgbSum), 255);
|
|
||||||
|
|
||||||
red *= cL;
|
uint8_t cLow = static_cast<uint8_t>(qMin(static_cast<int>(_sumBrightnessLow / rgbSum), UINT8_MAX));
|
||||||
green *= cL;
|
red *= cLow;
|
||||||
blue *= cL;
|
green *= cLow;
|
||||||
|
blue *= cLow;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
red = qMin((int)(_sumBrightnessLow/3.0), 255);
|
red = static_cast<uint8_t>(qMin(static_cast<int>(_sumBrightnessLow/3.0), UINT8_MAX));
|
||||||
green = red;
|
green = red;
|
||||||
blue = red;
|
blue = red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RgbTransform::setTemperature(int temperature)
|
||||||
|
{
|
||||||
|
_temperature = temperature;
|
||||||
|
_temperatureRGB = getRgbFromTemperature(_temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
int RgbTransform::getTemperature() const
|
||||||
|
{
|
||||||
|
return _temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbTransform::applyTemperature(ColorRgb& color) const
|
||||||
|
{
|
||||||
|
color.red = color.red * _temperatureRGB.red / UINT8_MAX;
|
||||||
|
color.green = color.green * _temperatureRGB.green / UINT8_MAX;
|
||||||
|
color.blue = color.blue * _temperatureRGB.blue / UINT8_MAX;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user