color_space icon indicating copy to clipboard operation
color_space copied to clipboard

A LAB -> RGB conversion produces negative values?

Open santoso-wijaya opened this issue 10 months ago • 0 comments

Aren't RGB values supposed to be positive in the [0, 255] range only?

Consider this:

    let lab = color_space::Lab::new(46.0, 0.0, -60.0);
    let rgb = lab.to_rgb();

    println!("RGB: {} {} {}", rgb.r, rgb.g, rgb.b);

This prints:

RGB: -263.1193150769503 115.19741519097205 210.19858655756587

The negative r value seems wrong, no?

I think the correct converted value is this: image

Was there supposed to be a zero-truncation happening when a component value goes negative in the ::to_rgb() implementation?

santoso-wijaya avatar Apr 09 '24 05:04 santoso-wijaya