mirror of
https://github.com/wled/WLED.git
synced 2025-07-09 20:06:33 +00:00
add inverse gamma 32 function and fix colors in pride (#4722)
* add inverse gamma 32 function and fix for colors in pride
This commit is contained in:
parent
00d1fcc5fb
commit
05f0630b9c
@ -1918,7 +1918,8 @@ uint16_t mode_colorwaves_pride_base(bool isPride2015) {
|
||||
bri8 += (255 - brightdepth);
|
||||
|
||||
if (isPride2015) {
|
||||
CRGB newcolor = CHSV(hue8, sat8, bri8);
|
||||
CRGBW newcolor = CRGB(CHSV(hue8, sat8, bri8));
|
||||
newcolor.color32 = gamma32inv(newcolor.color32);
|
||||
SEGMENT.blendPixelColor(i, newcolor, 64);
|
||||
} else {
|
||||
SEGMENT.blendPixelColor(i, SEGMENT.color_from_palette(hue8, false, PALETTE_SOLID_WRAP, 0, bri8), 128);
|
||||
|
@ -520,7 +520,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
CJSON(strip.autoSegments, light[F("aseg")]);
|
||||
CJSON(useRainbowWheel, light[F("rw")]);
|
||||
|
||||
CJSON(gammaCorrectVal, light["gc"]["val"]); // default 2.8
|
||||
CJSON(gammaCorrectVal, light["gc"]["val"]); // default 2.2
|
||||
float light_gc_bri = light["gc"]["bri"];
|
||||
float light_gc_col = light["gc"]["col"];
|
||||
if (light_gc_bri > 1.0f) gammaCorrectBri = true;
|
||||
|
@ -598,3 +598,17 @@ uint32_t IRAM_ATTR_YN NeoGammaWLEDMethod::Correct32(uint32_t color)
|
||||
b = gammaT[b];
|
||||
return RGBW32(r, g, b, w);
|
||||
}
|
||||
|
||||
uint32_t IRAM_ATTR_YN NeoGammaWLEDMethod::inverseGamma32(uint32_t color)
|
||||
{
|
||||
if (!gammaCorrectCol) return color;
|
||||
uint8_t w = W(color);
|
||||
uint8_t r = R(color);
|
||||
uint8_t g = G(color);
|
||||
uint8_t b = B(color);
|
||||
w = gammaT_inv[w];
|
||||
r = gammaT_inv[r];
|
||||
g = gammaT_inv[g];
|
||||
b = gammaT_inv[b];
|
||||
return RGBW32(r, g, b, w);
|
||||
}
|
||||
|
@ -158,6 +158,7 @@ class NeoGammaWLEDMethod {
|
||||
public:
|
||||
[[gnu::hot]] static uint8_t Correct(uint8_t value); // apply Gamma to single channel
|
||||
[[gnu::hot]] static uint32_t Correct32(uint32_t color); // apply Gamma to RGBW32 color (WLED specific, not used by NPB)
|
||||
[[gnu::hot]] static uint32_t inverseGamma32(uint32_t color); // apply inverse Gamma to RGBW32 color
|
||||
static void calcGammaTable(float gamma); // re-calculates & fills gamma tables
|
||||
static inline uint8_t rawGamma8(uint8_t val) { return gammaT[val]; } // get value from Gamma table (WLED specific, not used by NPB)
|
||||
static inline uint8_t rawInverseGamma8(uint8_t val) { return gammaT_inv[val]; } // get value from inverse Gamma table (WLED specific, not used by NPB)
|
||||
@ -167,6 +168,7 @@ class NeoGammaWLEDMethod {
|
||||
};
|
||||
#define gamma32(c) NeoGammaWLEDMethod::Correct32(c)
|
||||
#define gamma8(c) NeoGammaWLEDMethod::rawGamma8(c)
|
||||
#define gamma32inv(c) NeoGammaWLEDMethod::inverseGamma32(c)
|
||||
#define gamma8inv(c) NeoGammaWLEDMethod::rawInverseGamma8(c)
|
||||
[[gnu::hot, gnu::pure]] uint32_t color_blend(uint32_t c1, uint32_t c2 , uint8_t blend);
|
||||
inline uint32_t color_blend16(uint32_t c1, uint32_t c2, uint16_t b) { return color_blend(c1, c2, b >> 8); };
|
||||
|
Loading…
x
Reference in New Issue
Block a user