mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
internal/f32color: correct pre-multipled color conversion
Tweak a test color to avoid an off-by-1 rounding error after changing the conversion formula. Fixes gio#192 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -36,3 +36,18 @@ func TestNRGBAToLinearRGBA_Boundary(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinearToRGBARoundtrip(t *testing.T) {
|
||||
for col := 0; col <= 0xFF; col++ {
|
||||
for alpha := 0; alpha <= 0xFF; alpha++ {
|
||||
want := color.NRGBA{R: uint8(col), A: uint8(alpha)}
|
||||
if alpha == 0 {
|
||||
want.R = 0
|
||||
}
|
||||
got := LinearFromSRGB(want).SRGB()
|
||||
if want != got {
|
||||
t.Errorf("got %v expected %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user