diff --git a/image/color/hsv.go b/image/color/hsv.go index 80334ea..2d2495d 100644 --- a/image/color/hsv.go +++ b/image/color/hsv.go @@ -67,12 +67,7 @@ func (hsva HSVA) RGBA () (r, g, b, a uint32) { S: hsva.S, V: hsva.V, }.RGBA() - a = uint32(hsva.A) - // alpha premultiplication - r = (r * a) / 0xFFFF - g = (g * a) / 0xFFFF - b = (b * a) / 0xFFFF - return + return Premultiply(r, g, b, uint32(hsva.A)) } // Canon returns the color but with the H, S, and V fields are constrained to @@ -104,11 +99,7 @@ func hsvModel (c color.Color) color.Color { case HSV: return c case HSVA: return HSV { H: c.H, S: c.S, V: c.V } default: - r, g, b, a := c.RGBA() - // alpha unpremultiplication - r = (r / a) * 0xFFFF - g = (g / a) * 0xFFFF - b = (b / a) * 0xFFFF + r, g, b, _ := Unpremultiply(c.RGBA()) return rgbToHSV(r, g, b) } }