diff options
Diffstat (limited to 'src/colour.c')
-rw-r--r-- | src/colour.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/colour.c b/src/colour.c index ad65b5f..4d85cb5 100644 --- a/src/colour.c +++ b/src/colour.c @@ -49,6 +49,7 @@ colour_setting_diff_is_major(const struct colour_setting *a, const struct colour * Fill a gamma ramp * * @param ramp The gamma ramp + * @param saved Saved gamma ramp with calibrations to preserver, or `NULL` * @param size The gamma ramp size (number of stops) * @param brightness The brightness (between 0 and 1) of the channel, which is * the overall applied brightness multiplied but the effect @@ -56,7 +57,7 @@ colour_setting_diff_is_major(const struct colour_setting *a, const struct colour * @param gamma The gamma to apply to the channel */\ static void\ - fill_ramp_##SUFFIX(TYPE *ramp, size_t size, double brightness, double gamma)\ + fill_ramp_##SUFFIX(TYPE *ramp, const TYPE *saved, size_t size, double brightness, double gamma)\ {\ size_t i;\ double v;\ @@ -72,18 +73,25 @@ colour_setting_diff_is_major(const struct colour_setting *a, const struct colour ramp[i] = (TYPE)v;\ }\ }\ + if (saved) {\ + for (i = 0; i < size; i++) {\ + v = (double)ramp[i] / (MAX) * (size - 1U);\ + ramp[i] = saved[(size_t)v];\ + }\ + }\ }\ \ void\ fill_ramps_##SUFFIX(TYPE *gamma_r, TYPE *gamma_g, TYPE *gamma_b,\ + const TYPE *saved_r, const TYPE *saved_g, const TYPE *saved_b,\ size_t size_r, size_t size_g, size_t size_b,\ const struct colour_setting *setting)\ {\ double r = 1, g = 1, b = 1;\ libred_get_colour(setting->temperature, &r, &g, &b);\ - fill_ramp_##SUFFIX(gamma_r, size_r, setting->brightness * r, setting->gamma[0]);\ - fill_ramp_##SUFFIX(gamma_g, size_g, setting->brightness * g, setting->gamma[1]);\ - fill_ramp_##SUFFIX(gamma_b, size_b, setting->brightness * b, setting->gamma[2]);\ + fill_ramp_##SUFFIX(gamma_r, saved_r, size_r, setting->brightness * r, setting->gamma[0]);\ + fill_ramp_##SUFFIX(gamma_g, saved_g, size_g, setting->brightness * g, setting->gamma[1]);\ + fill_ramp_##SUFFIX(gamma_b, saved_b, size_b, setting->brightness * b, setting->gamma[2]);\ } LIST_RAMPS_STOP_VALUE_TYPES(X,) |