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:
Elias Naur
2021-01-15 16:01:18 +01:00
parent 85c0a7d803
commit 01d5e72291
3 changed files with 23 additions and 8 deletions
+15
View File
@@ -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)
}
}
}
}