fix Sixel HLS interpretation
Two issues here: * The hue angles need adjusting to work with the palette library * The resultant RGB color had the wrong gamma level, resulting in an overly bright image. refs: https://github.com/wez/wezterm/issues/775
This commit is contained in:
1 parent
5f5a48c830
commit
01de37b709
2 files changed
+11
-4
No files matched your search
@@ -17,6 +17,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Fixed: `wezterm cli split-pane` didn't use the current working dir of the source pane. [#766](https://github.com/wez/wezterm/issues/766)
|
||||
* Fixed: double-click-drag selection could panic when crossing line boundaries [#762](https://github.com/wez/wezterm/issues/762)
|
||||
* Fixed: wrong scaling for ligatures in Recursive Mono font [#699](https://github.com/wez/wezterm/issues/699)
|
||||
* Fixed: incorrect Sixel HLS hue handling [#775](https://github.com/wez/wezterm/issues/775)
|
||||
|
||||
### 20210502-154244-3f7122cb
|
||||
|
||||
|
||||
@@ -1500,13 +1500,19 @@ impl TerminalState {
|
||||
lightness,
|
||||
} => {
|
||||
use palette::encoding::pixel::Pixel;
|
||||
let hue = palette::RgbHue::from_degrees(*hue_angle as f32);
|
||||
// Sixel's hue angles are: blue=0, red=120, green=240,
|
||||
// whereas Hsl has red=0, green=120, blue=240.
|
||||
// Looking at red, we need to rotate left by 120 to
|
||||
// go from sixel red to palette::RgbHue red.
|
||||
// Negative values wrap around the circle.
|
||||
// https://github.com/wez/wezterm/issues/775
|
||||
let angle = (*hue_angle as f32) - 120.0;
|
||||
let angle = if angle < 0. { 360.0 + angle } else { angle };
|
||||
let hue = palette::RgbHue::from_degrees(angle);
|
||||
let hsl =
|
||||
palette::Hsl::new(hue, *saturation as f32 / 100., *lightness as f32 / 100.);
|
||||
let rgb: palette::Srgb = hsl.into();
|
||||
let rgb: [u8; 3] = palette::Srgb::from_linear(rgb.into_linear())
|
||||
.into_format()
|
||||
.into_raw();
|
||||
let rgb: [u8; 3] = rgb.into_linear().into_format().into_raw();
|
||||
|
||||
color_map.insert(*color_number, RgbColor::new(rgb[0], rgb[1], rgb[2]));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user