From 9655da5841f661ded2ab2c02597c50046064e30c Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Tue, 10 Sep 2024 17:42:45 -0400 Subject: [PATCH] HSV uses Premultiply and Unpremultiply functions --- image/color/hsv.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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) } }