hyperion.ng/libsrc/utils/RgbChannelAdjustment.cpp
AEtHeLsYn b37cbd26d5 Add color adjustment to all RBG channels
* Channel adjustment config

* Create RgbChannelAdjustment.h

* Delete RgbChannelAdjustment.h

* Create RgbChannelAdjustment.cpp

* Create RgbChannelAdjustment.h

* Delete RgbChannelAdjustment.cpp

* Create ColorAdjustment.cpp

* Delete RgbChannelAdjustment.h

* Create ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.cpp

* Update Hyperion.cpp

* Update Hyperion.cpp

* Update Hyperion.cpp

* Update Hyperion.h

* Create RgbChannelAdjustment.cpp

* Create RgbChannelAdjustment.h

* Create ColorAdjustment.h

* Create MultiColorAdjustment.h

* Update MultiColorAdjustment.h

* Create MultiColorAdjustment.cpp

* Delete ColorAdjustment.cpp

* Delete ColorAdjustment.h

* Update RgbChannelAdjustment.cpp

* Update Hyperion.cpp

* Update Hyperion.h

* Update Hyperion.cpp

* Bug fixes

* Update hyperion.config.json

* Add color adjustment to json server and client and adapt hyperion-remote

* Change the color modification order

* Minor bug fix

* Create calibration Images folder

* Create calibration Gamma folder

* Create calibration RGB folder

* Added files via upload

* Delete .gitkeep

* Delete .gitkeep

* Added files via upload

* Delete .gitkeep

* Update color effect order and don't correct twice

* Uploaded gradient images


Former-commit-id: 8ab465e59834f12a21709a6f4546bd6808a2a495
2016-04-02 00:04:11 +02:00

108 lines
1.8 KiB
C++

// STL includes
#include <cmath>
// Utils includes
#include <utils/RgbChannelAdjustment.h>
RgbChannelAdjustment::RgbChannelAdjustment() :
_adjustR(255),
_adjustG(255),
_adjustB(255)
{
initializeMapping();
}
RgbChannelAdjustment::RgbChannelAdjustment(int adjustR, int adjustG, int adjustB) :
_adjustR(adjustR),
_adjustG(adjustG),
_adjustB(adjustB)
{
initializeMapping();
}
RgbChannelAdjustment::~RgbChannelAdjustment()
{
}
uint8_t RgbChannelAdjustment::getadjustmentR() const
{
return _adjustR;
}
void RgbChannelAdjustment::setadjustmentR(uint8_t adjustR)
{
_adjustR = adjustR;
initializeMapping();
}
uint8_t RgbChannelAdjustment::getadjustmentG() const
{
return _adjustG;
}
void RgbChannelAdjustment::setadjustmentG(uint8_t adjustG)
{
_adjustG = adjustG;
initializeMapping();
}
uint8_t RgbChannelAdjustment::getadjustmentB() const
{
return _adjustB;
}
void RgbChannelAdjustment::setadjustmentB(uint8_t adjustB)
{
_adjustB = adjustB;
initializeMapping();
}
uint8_t RgbChannelAdjustment::adjustmentR(uint8_t inputR) const
{
return _mappingR[inputR];
}
uint8_t RgbChannelAdjustment::adjustmentG(uint8_t inputG) const
{
return _mappingG[inputG];
}
uint8_t RgbChannelAdjustment::adjustmentB(uint8_t inputB) const
{
return _mappingB[inputB];
}
void RgbChannelAdjustment::initializeMapping()
{
// initialize the mapping
for (int i = 0; i < 256; ++i)
{
int outputR = (i * _adjustR) / 255;
if (outputR > 255)
{
outputR = 255;
}
_mappingR[i] = outputR;
}
for (int i = 0; i < 256; ++i)
{
int outputG = (i * _adjustG) / 255;
if (outputG > 255)
{
outputG = 255;
}
_mappingG[i] = outputG;
}
for (int i = 0; i < 256; ++i)
{
int outputB = (i * _adjustB) / 255;
if (outputB > 255)
{
outputB = 255;
}
_mappingB[i] = outputB;
}
}