[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pdf-tools a99b8fd409 2/5: Fix: high contrast render in mid
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pdf-tools a99b8fd409 2/5: Fix: high contrast render in midnight mode |
Date: |
Sat, 10 Jun 2023 13:01:46 -0400 (EDT) |
branch: elpa/pdf-tools
commit a99b8fd409284506fc6388f1a529f5b79e838842
Author: Zero <46195892+Atreyagaurav@users.noreply.github.com>
Commit: Vedang Manerikar <ved.manerikar@gmail.com>
Fix: high contrast render in midnight mode
Uses the Lightness values from the `pdf-view-midnight-colors` `fg` and
`bg` to scale the inverted color's lightness. Band-aid till better
method is found.
Relates to: #69
---
server/epdfinfo.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/server/epdfinfo.c b/server/epdfinfo.c
index b82cb6fca7..ef14e41e57 100644
--- a/server/epdfinfo.c
+++ b/server/epdfinfo.c
@@ -508,6 +508,9 @@ image_recolor (cairo_surface_t * surface, const
PopplerColor * fg,
.g = rgb_bg.g - rgb_fg.g,
.b = rgb_bg.b - rgb_fg.b
};
+ const double fg_l = a[0] * rgb_fg.r + a[1] * rgb_fg.g + a[2] * rgb_fg.b;
+ const double bg_l = a[0] * rgb_bg.r + a[1] * rgb_bg.g + a[2] * rgb_bg.b;
+ const double diff_l = fg_l - bg_l;
/* The Oklab transform is expensive, precompute white->black and have a
single
entry cache to speed up computation */
@@ -576,8 +579,8 @@ image_recolor (cairo_surface_t * surface, const
PopplerColor * fg,
* 'feel' too dark and fonts too thin otherwise. */
oklab.l = pow(oklab.l, 1.8);
- /* Invert the perceived lightness */
- oklab.l = 1.0 - oklab.l;
+ /* Invert the perceived lightness, and scales it */
+ oklab.l = bg_l + diff_l * (1.0 - oklab.l);
rgb = oklab2rgb(oklab);