forked from joejulian/gio
internal/f32color: delete unused NRGBAToRGBA_PostAlpha
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -93,24 +93,6 @@ func NRGBAToLinearRGBA(col color.NRGBA) color.RGBA {
|
||||
}
|
||||
}
|
||||
|
||||
// NRGBAToRGBA_PostAlpha converts from non-premultiplied sRGB color to premultiplied sRGB color.
|
||||
//
|
||||
// Each component in the result is `sRGBToLinear(c) * alpha`, where `c`
|
||||
// is the linear color.
|
||||
func NRGBAToRGBA_PostAlpha(col color.NRGBA) color.RGBA {
|
||||
if col.A == 0xFF {
|
||||
return color.RGBA(col)
|
||||
} else if col.A == 0x00 {
|
||||
return color.RGBA{}
|
||||
}
|
||||
return color.RGBA{
|
||||
R: uint8(uint32(col.R) * uint32(col.A) / 0xFF),
|
||||
G: uint8(uint32(col.G) * uint32(col.A) / 0xFF),
|
||||
B: uint8(uint32(col.B) * uint32(col.A) / 0xFF),
|
||||
A: col.A,
|
||||
}
|
||||
}
|
||||
|
||||
// RGBAToNRGBA converts from premultiplied sRGB color to non-premultiplied sRGB color.
|
||||
func RGBAToNRGBA(col color.RGBA) color.NRGBA {
|
||||
if col.A == 0xFF {
|
||||
|
||||
@@ -7,21 +7,6 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNRGBAToRGBA_PostAlpha_Boundary(t *testing.T) {
|
||||
for col := 0; col <= 0xFF; col++ {
|
||||
for alpha := 0; alpha <= 0xFF; alpha++ {
|
||||
in := color.NRGBA{R: uint8(col), A: uint8(alpha)}
|
||||
premul := NRGBAToRGBA_PostAlpha(in)
|
||||
if premul.A != uint8(alpha) {
|
||||
t.Errorf("%v: got %v expected %v", in, premul.A, alpha)
|
||||
}
|
||||
if premul.R > premul.A {
|
||||
t.Errorf("%v: R=%v > A=%v", in, premul.R, premul.A)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNRGBAToLinearRGBA_Boundary(t *testing.T) {
|
||||
for col := 0; col <= 0xFF; col++ {
|
||||
for alpha := 0; alpha <= 0xFF; alpha++ {
|
||||
|
||||
Reference in New Issue
Block a user