Hacker News new | ask | show | jobs
by virtualritz 10 days ago
255.0. Everything else makes no sense and is actually dangerous when working with colors. Trust me. :)

And when you go from float to 8bit you should dither to avoid banding.

If in doubt, error diffusion with a random number between -0.5..=0.5 is fine. 0.5 here is dither_amplitude:

round(255 * input_value + dither_amplitude * random(-1, 1))

See e.g. my dithereens crate: https://crates.io/crates/dithereens