2017-01-06 14:25:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Color transformation to adjust the saturation and value of a RGB color value
|
|
|
|
///
|
|
|
|
class RgbTransform
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
/// Default constructor
|
|
|
|
///
|
|
|
|
RgbTransform();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Constructor
|
|
|
|
///
|
|
|
|
/// @param gammaR The used red gamma
|
|
|
|
/// @param gammaG The used green gamma
|
|
|
|
/// @param gammab The used blue gamma
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param backlightThreshold The used lower brightness
|
|
|
|
/// @param backlightColored use color in backlight
|
2017-01-06 14:25:55 +01:00
|
|
|
/// @param brightnessHigh The used higher brightness
|
|
|
|
///
|
2017-04-03 05:19:05 +02:00
|
|
|
RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation);
|
2017-01-06 14:25:55 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Destructor
|
|
|
|
///
|
|
|
|
~RgbTransform();
|
|
|
|
|
|
|
|
/// @return The current red gamma value
|
|
|
|
double getGammaR() const;
|
|
|
|
|
|
|
|
/// @return The current green gamma value
|
|
|
|
double getGammaG() const;
|
|
|
|
|
|
|
|
/// @return The current blue gamma value
|
|
|
|
double getGammaB() const;
|
|
|
|
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param gammaR New red gamma value
|
|
|
|
/// @param gammaG New green gamma value
|
|
|
|
/// @param gammaB New blue gamma value
|
2017-01-06 14:25:55 +01:00
|
|
|
void setGamma(double gammaR,double gammaG=-1, double gammaB=-1);
|
|
|
|
|
|
|
|
/// @return The current lower brightness
|
2017-04-03 05:19:05 +02:00
|
|
|
int getBacklightThreshold() const;
|
2017-01-06 14:25:55 +01:00
|
|
|
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param backlightThreshold New lower brightness
|
2017-04-03 05:19:05 +02:00
|
|
|
void setBacklightThreshold(int backlightThreshold);
|
2017-01-06 14:25:55 +01:00
|
|
|
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @return The current state
|
|
|
|
bool getBacklightColored() const;
|
|
|
|
|
|
|
|
/// @param backlightColored en/disable colored backlight
|
|
|
|
void setBacklightColored(bool backlightColored);
|
|
|
|
|
|
|
|
/// @return return state of backlight
|
|
|
|
bool getBackLightEnabled() const;
|
|
|
|
|
|
|
|
/// @param enable en/disable backlight
|
|
|
|
void setBackLightEnabled(bool enable);
|
|
|
|
|
|
|
|
/// @return The current brightness
|
2017-04-03 05:19:05 +02:00
|
|
|
uint8_t getBrightness() const;
|
2017-01-06 14:25:55 +01:00
|
|
|
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param brightness New brightness
|
2017-04-03 05:19:05 +02:00
|
|
|
void setBrightness(uint8_t brightness);
|
|
|
|
|
|
|
|
/// @return The current brightnessCompensation value
|
|
|
|
uint8_t getBrightnessCompensation() const;
|
|
|
|
|
|
|
|
/// @param brightnessCompensation new brightnessCompensation
|
|
|
|
void setBrightnessCompensation(uint8_t brightnessCompensation);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// get component values of brightness for compensated brightness
|
|
|
|
///
|
|
|
|
/// @param rgb the rgb component
|
|
|
|
/// @param cmy the cyan magenta yellow component
|
|
|
|
/// @param w the white component
|
|
|
|
///
|
|
|
|
/// @note The values are updated in place.
|
|
|
|
///
|
|
|
|
void getBrightnessComponents(uint8_t & rgb, uint8_t & cmy, uint8_t & w );
|
2017-01-06 14:25:55 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Apply the transform 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 transform(uint8_t & red, uint8_t & green, uint8_t & blue);
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
/// init
|
|
|
|
///
|
|
|
|
/// @param gammaR The used red gamma
|
|
|
|
/// @param gammaG The used green gamma
|
|
|
|
/// @param gammab The used blue gamma
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param backlightThreshold The used lower brightness
|
|
|
|
/// @param backlightColored en/disable color in backlight
|
2017-04-03 05:19:05 +02:00
|
|
|
/// @param brightness The used brightness
|
|
|
|
/// @param brightnessCompensation The used brightness compensation
|
2017-01-06 14:25:55 +01:00
|
|
|
///
|
2017-04-03 05:19:05 +02:00
|
|
|
void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, uint8_t brightness, uint8_t brightnessCompensation);
|
2017-01-06 14:25:55 +01:00
|
|
|
|
|
|
|
/// (re)-initilize the color mapping
|
|
|
|
void initializeMapping(); /// The saturation gain
|
|
|
|
|
2017-04-03 05:19:05 +02:00
|
|
|
void updateBrightnessComponents();
|
|
|
|
|
|
|
|
/// backlight variables
|
2019-07-09 23:07:31 +02:00
|
|
|
bool _backLightEnabled
|
|
|
|
, _backlightColored;
|
|
|
|
double _backlightThreshold
|
|
|
|
, _sumBrightnessLow;
|
2017-01-06 14:25:55 +01:00
|
|
|
|
2017-04-03 05:19:05 +02:00
|
|
|
/// gamma variables
|
2019-07-09 23:07:31 +02:00
|
|
|
double _gammaR
|
|
|
|
, _gammaG
|
|
|
|
, _gammaB;
|
2017-01-06 14:25:55 +01:00
|
|
|
|
|
|
|
/// The mapping from input color to output color
|
2019-07-09 23:07:31 +02:00
|
|
|
uint8_t _mappingR[256]
|
|
|
|
, _mappingG[256]
|
|
|
|
, _mappingB[256];
|
2017-02-11 22:52:47 +01:00
|
|
|
|
2017-04-03 05:19:05 +02:00
|
|
|
/// brightness variables
|
2019-07-09 23:07:31 +02:00
|
|
|
uint8_t _brightness
|
|
|
|
, _brightnessCompensation
|
|
|
|
, _brightness_rgb
|
|
|
|
, _brightness_cmy
|
|
|
|
, _brightness_w;
|
2017-01-06 14:25:55 +01:00
|
|
|
};
|