diff options
| author | Zero <46195892+Atreyagaurav@users.noreply.github.com> | 2023-03-02 22:26:54 -0500 |
|---|---|---|
| committer | Vedang Manerikar <ved.manerikar@gmail.com> | 2023-06-10 20:05:15 +0530 |
| commit | a99b8fd409284506fc6388f1a529f5b79e838842 (patch) | |
| tree | c069bdbd11416dc3b6880ae0798701ff088599fb /server | |
| parent | d076cc9c6e11e85d79aa372715986e8fc6fd2836 (diff) | |
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
Diffstat (limited to 'server')
| -rw-r--r-- | server/epdfinfo.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/server/epdfinfo.c b/server/epdfinfo.c index b82cb6f..ef14e41 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); |
