egui/crates/ecolor/src
Emil Ernerfeldt 3f731ec794
Fix semi-transparent colors appearing too bright (#5824)
The bug was in `Color32::from_rgba_unmultiplied` and by extension
affects:

* `Color32::from_rgba_unmultiplied`
* `hex_color!`
* `HexColor`
* `ColorImage::from_rgba_unmultiplied`
* All images with transparency (png, webp, …)
* `Color32::from_white_alpha`

The bug caused translucent colors to appear too bright.

## More
Color is hard.

When I started out egui I thought "linear space is objectively better,
for everything!" and then I've been slowly walking that back for various
reasons:

* sRGB textures not available everywhere
* gamma-space is more _perceptually_ even, so it makes sense to use for
anti-aliasing
* other applications do everything in gamma space, so that's what people
expect (this PR)

Similarly, pre-multiplied alpha _makes sense_ for blending colors. It
also enables additive colors, which is nice. But it does complicate
things. Especially when mixed with sRGB/gamma (As @karhu [points
out](https://github.com/emilk/egui/pull/5824#issuecomment-2738099254)).

## Related
* Closes https://github.com/emilk/egui/issues/5751
* Closes https://github.com/emilk/egui/issues/5771 ? (probably; hard to
tell without a repro)
* But not https://github.com/emilk/egui/issues/5810

## TODO
* [x] I broke the RGBA u8 color picker. Fix it

---------

Co-authored-by: Andreas Reich <andreas@rerun.io>
2025-03-21 10:45:25 +01:00
..
cint_impl.rs Remove wildcard imports (#5018) 2024-08-28 12:18:42 +02:00
color32.rs Fix semi-transparent colors appearing too bright (#5824) 2025-03-21 10:45:25 +01:00
hex_color_macro.rs Update MSRV from 1.76 to 1.77 (#5322) 2024-10-30 09:06:34 +01:00
hex_color_runtime.rs Fix semi-transparent colors appearing too bright (#5824) 2025-03-21 10:45:25 +01:00
hsva.rs Fix semi-transparent colors appearing too bright (#5824) 2025-03-21 10:45:25 +01:00
hsva_gamma.rs Use `Self` everywhere (#3787) 2024-01-08 17:41:21 +01:00
lib.rs Fix semi-transparent colors appearing too bright (#5824) 2025-03-21 10:45:25 +01:00
rgba.rs Fix semi-transparent colors appearing too bright (#5824) 2025-03-21 10:45:25 +01:00