Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed gamma correction according to CIE LAB #242

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/internal/NeoEase.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ class NeoEase

static float Gamma(float unitValue)
{
return pow(unitValue, 1.0f / 0.45f);
unitValue = unitValue * 100.0f;
if(unitValue <= 8)
{
return unitValue / 903.3f;
}
else
{
return pow((unitValue + 16.0f) / 116.0f, 3.0f);
}
}
};
12 changes: 2 additions & 10 deletions src/internal/NeoGamma.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,9 @@ License along with NeoPixel. If not, see
class NeoGammaEquationMethod
{
public:
static uint8_t Correct(float value)
static uint8_t Correct(uint8_t value)
{
value = value / 255.0f * 100.0f;
if(value <= 8)
{
return static_cast<uint8_t>(round(value / 903.3f * 255.0f));
}
else
{
return static_cast<uint8_t>(round(pow((value + 16.0f) / 116.0f, 3.0f) * 255.0f));
}
return static_cast<uint8_t>(255.0f * NeoEase::Gamma(value / 255.0f) + 0.5f);
}
};

Expand Down