internal/affine: create a fast path for ChangeHSV

When hue = 0 and saturation = 1, this should be the same as scaling.

Closes #2170
This commit is contained in:
Hajime Hoshi 2022-06-30 11:32:08 +09:00
parent a9c9e18ff4
commit 8cdfa4f66c

View File

@ -761,6 +761,11 @@ var (
//
// This conversion uses RGB to/from YCrCb conversion.
func ChangeHSV(c ColorM, hueTheta float64, saturationScale float32, valueScale float32) ColorM {
if hueTheta == 0 && saturationScale == 1 {
v := valueScale
return c.Scale(v, v, v, 1)
}
sin, cos := math.Sincos(hueTheta)
s32, c32 := float32(sin), float32(cos)
c = c.Concat(rgbToYCbCr)