git.lucas.co / go_mono
git clone https://git.lucas.co/go_mono.git

commitdf2aa51d4407e30b309afc8c4d6fdca045d97fb0
parent05f0a469d9
authorNigel Tao <[email protected]>
date2017-02-10 14:20
draw: tweak the YCbCr to RGBA conversion formula again.

This is the golang.org/x equivalent of the golang.org/cl/36732 change to
the standard library.

Change-Id: I71c09a72e24c8e1c013769a6fed8f9a031724d9d
Reviewed-on: https://go-review.googlesource.com/36733
Run-TryBot: Nigel Tao <[email protected]>
Reviewed-by: Rob Pike <[email protected]>

 draw/gen.go                         |   2 +-
 draw/impl.go                        |  96 ++++++++++++++++++------------------
 draw/stdlib_test.go                 |   6 +--
 testdata/go-turns-two-down-ab.png   | Bin 21338 -> 21092 bytes
 testdata/go-turns-two-down-bl.png   | Bin 18581 -> 18169 bytes
 testdata/go-turns-two-down-cr.png   | Bin 19519 -> 19141 bytes
 testdata/go-turns-two-down-nn.png   | Bin 21504 -> 21320 bytes
 testdata/go-turns-two-rotate-ab.png | Bin 7654 -> 7417 bytes
 testdata/go-turns-two-rotate-bl.png | Bin 7653 -> 7421 bytes
 testdata/go-turns-two-rotate-cr.png | Bin 7808 -> 7544 bytes
 testdata/go-turns-two-rotate-nn.png | Bin 4915 -> 5128 bytes
 testdata/go-turns-two-up-ab.png     | Bin 9633 -> 9427 bytes
 testdata/go-turns-two-up-bl.png     | Bin 9639 -> 9427 bytes
 testdata/go-turns-two-up-cr.png     | Bin 10987 -> 10694 bytes
 testdata/go-turns-two-up-nn.png     | Bin 1368 -> 1369 bytes
 testdata/tux-rotate-ab.png          | Bin 3237 -> 3340 bytes
 testdata/tux-rotate-bl.png          | Bin 3751 -> 3836 bytes
 testdata/tux-rotate-cr.png          | Bin 3753 -> 3841 bytes
 testdata/tux-rotate-nn.png          | Bin 3055 -> 3159 bytes
 19 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/draw/gen.go b/draw/gen.go
index 0fed474..65a7123 100644
--- a/draw/gen.go
+++ b/draw/gen.go
@@ -804,7 +804,7 @@ func cOffset(x, y, sratio string) string {
 func ycbcrToRGB(lhs, tmp string) string {
 	s := `
 		// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-		$yy1 := int(src.Y[$i]) * 0x10100
+		$yy1 := int(src.Y[$i]) * 0x10101
 		$cb1 := int(src.Cb[$j]) - 128
 		$cr1 := int(src.Cr[$j]) - 128
 		$r@ := ($yy1 + 91881*$cr1) >> 8
diff --git a/draw/impl.go b/draw/impl.go
index d6484d7..637887b 100644
--- a/draw/impl.go
+++ b/draw/impl.go
@@ -343,7 +343,7 @@ func (nnInterpolator) scale_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Rec
 			pj := (sr.Min.Y+int(sy)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(sx) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -386,7 +386,7 @@ func (nnInterpolator) scale_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Rec
 			pj := (sr.Min.Y+int(sy)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(sx))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -429,7 +429,7 @@ func (nnInterpolator) scale_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Rec
 			pj := ((sr.Min.Y+int(sy))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(sx))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -472,7 +472,7 @@ func (nnInterpolator) scale_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Rec
 			pj := ((sr.Min.Y+int(sy))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(sx) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -759,7 +759,7 @@ func (nnInterpolator) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image
 			pj := (sy0-src.Rect.Min.Y)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -803,7 +803,7 @@ func (nnInterpolator) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image
 			pj := (sy0-src.Rect.Min.Y)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -847,7 +847,7 @@ func (nnInterpolator) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image
 			pj := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -891,7 +891,7 @@ func (nnInterpolator) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image
 			pj := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			pyy1 := int(src.Y[pi]) * 0x10100
+			pyy1 := int(src.Y[pi]) * 0x10101
 			pcb1 := int(src.Cb[pj]) - 128
 			pcr1 := int(src.Cr[pj]) - 128
 			pr := (pyy1 + 91881*pcr1) >> 8
@@ -1756,7 +1756,7 @@ func (ablInterpolator) scale_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Re
 			s00j := (sr.Min.Y+int(sy0)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(sx0) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -1785,7 +1785,7 @@ func (ablInterpolator) scale_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Re
 			s10j := (sr.Min.Y+int(sy0)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(sx1) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -1817,7 +1817,7 @@ func (ablInterpolator) scale_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Re
 			s01j := (sr.Min.Y+int(sy1)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(sx0) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -1846,7 +1846,7 @@ func (ablInterpolator) scale_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Re
 			s11j := (sr.Min.Y+int(sy1)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(sx1) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -1931,7 +1931,7 @@ func (ablInterpolator) scale_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Re
 			s00j := (sr.Min.Y+int(sy0)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(sx0))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -1960,7 +1960,7 @@ func (ablInterpolator) scale_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Re
 			s10j := (sr.Min.Y+int(sy0)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(sx1))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -1992,7 +1992,7 @@ func (ablInterpolator) scale_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Re
 			s01j := (sr.Min.Y+int(sy1)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(sx0))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -2021,7 +2021,7 @@ func (ablInterpolator) scale_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Re
 			s11j := (sr.Min.Y+int(sy1)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(sx1))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -2106,7 +2106,7 @@ func (ablInterpolator) scale_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Re
 			s00j := ((sr.Min.Y+int(sy0))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(sx0))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -2135,7 +2135,7 @@ func (ablInterpolator) scale_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Re
 			s10j := ((sr.Min.Y+int(sy0))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(sx1))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -2167,7 +2167,7 @@ func (ablInterpolator) scale_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Re
 			s01j := ((sr.Min.Y+int(sy1))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(sx0))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -2196,7 +2196,7 @@ func (ablInterpolator) scale_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Re
 			s11j := ((sr.Min.Y+int(sy1))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(sx1))/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -2281,7 +2281,7 @@ func (ablInterpolator) scale_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Re
 			s00j := ((sr.Min.Y+int(sy0))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(sx0) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -2310,7 +2310,7 @@ func (ablInterpolator) scale_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Re
 			s10j := ((sr.Min.Y+int(sy0))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(sx1) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -2342,7 +2342,7 @@ func (ablInterpolator) scale_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Re
 			s01j := ((sr.Min.Y+int(sy1))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(sx0) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -2371,7 +2371,7 @@ func (ablInterpolator) scale_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Re
 			s11j := ((sr.Min.Y+int(sy1))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(sx1) - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -3345,7 +3345,7 @@ func (ablInterpolator) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr imag
 			s00j := (sy0-src.Rect.Min.Y)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -3374,7 +3374,7 @@ func (ablInterpolator) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr imag
 			s10j := (sy0-src.Rect.Min.Y)*src.CStride + (sx1 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -3406,7 +3406,7 @@ func (ablInterpolator) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr imag
 			s01j := (sy1-src.Rect.Min.Y)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -3435,7 +3435,7 @@ func (ablInterpolator) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr imag
 			s11j := (sy1-src.Rect.Min.Y)*src.CStride + (sx1 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -3521,7 +3521,7 @@ func (ablInterpolator) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr imag
 			s00j := (sy0-src.Rect.Min.Y)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -3550,7 +3550,7 @@ func (ablInterpolator) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr imag
 			s10j := (sy0-src.Rect.Min.Y)*src.CStride + ((sx1)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -3582,7 +3582,7 @@ func (ablInterpolator) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr imag
 			s01j := (sy1-src.Rect.Min.Y)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -3611,7 +3611,7 @@ func (ablInterpolator) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr imag
 			s11j := (sy1-src.Rect.Min.Y)*src.CStride + ((sx1)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -3697,7 +3697,7 @@ func (ablInterpolator) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr imag
 			s00j := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -3726,7 +3726,7 @@ func (ablInterpolator) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr imag
 			s10j := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + ((sx1)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -3758,7 +3758,7 @@ func (ablInterpolator) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr imag
 			s01j := ((sy1)/2-src.Rect.Min.Y/2)*src.CStride + ((sx0)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -3787,7 +3787,7 @@ func (ablInterpolator) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr imag
 			s11j := ((sy1)/2-src.Rect.Min.Y/2)*src.CStride + ((sx1)/2 - src.Rect.Min.X/2)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -3873,7 +3873,7 @@ func (ablInterpolator) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr imag
 			s00j := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s00yy1 := int(src.Y[s00i]) * 0x10100
+			s00yy1 := int(src.Y[s00i]) * 0x10101
 			s00cb1 := int(src.Cb[s00j]) - 128
 			s00cr1 := int(src.Cr[s00j]) - 128
 			s00ru := (s00yy1 + 91881*s00cr1) >> 8
@@ -3902,7 +3902,7 @@ func (ablInterpolator) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr imag
 			s10j := ((sy0)/2-src.Rect.Min.Y/2)*src.CStride + (sx1 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s10yy1 := int(src.Y[s10i]) * 0x10100
+			s10yy1 := int(src.Y[s10i]) * 0x10101
 			s10cb1 := int(src.Cb[s10j]) - 128
 			s10cr1 := int(src.Cr[s10j]) - 128
 			s10ru := (s10yy1 + 91881*s10cr1) >> 8
@@ -3934,7 +3934,7 @@ func (ablInterpolator) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr imag
 			s01j := ((sy1)/2-src.Rect.Min.Y/2)*src.CStride + (sx0 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s01yy1 := int(src.Y[s01i]) * 0x10100
+			s01yy1 := int(src.Y[s01i]) * 0x10101
 			s01cb1 := int(src.Cb[s01j]) - 128
 			s01cr1 := int(src.Cr[s01j]) - 128
 			s01ru := (s01yy1 + 91881*s01cr1) >> 8
@@ -3963,7 +3963,7 @@ func (ablInterpolator) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr imag
 			s11j := ((sy1)/2-src.Rect.Min.Y/2)*src.CStride + (sx1 - src.Rect.Min.X)
 
 			// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-			s11yy1 := int(src.Y[s11i]) * 0x10100
+			s11yy1 := int(src.Y[s11i]) * 0x10101
 			s11cb1 := int(src.Cb[s11j]) - 128
 			s11cr1 := int(src.Cr[s11j]) - 128
 			s11ru := (s11yy1 + 91881*s11cr1) >> 8
@@ -4729,7 +4729,7 @@ func (z *kernelScaler) scaleX_YCbCr444(tmp [][4]float64, src *image.YCbCr, sr im
 				pj := (sr.Min.Y+int(y)-src.Rect.Min.Y)*src.CStride + (sr.Min.X + int(c.coord) - src.Rect.Min.X)
 
 				// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-				pyy1 := int(src.Y[pi]) * 0x10100
+				pyy1 := int(src.Y[pi]) * 0x10101
 				pcb1 := int(src.Cb[pj]) - 128
 				pcr1 := int(src.Cr[pj]) - 128
 				pru := (pyy1 + 91881*pcr1) >> 8
@@ -4776,7 +4776,7 @@ func (z *kernelScaler) scaleX_YCbCr422(tmp [][4]float64, src *image.YCbCr, sr im
 				pj := (sr.Min.Y+int(y)-src.Rect.Min.Y)*src.CStride + ((sr.Min.X+int(c.coord))/2 - src.Rect.Min.X/2)
 
 				// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-				pyy1 := int(src.Y[pi]) * 0x10100
+				pyy1 := int(src.Y[pi]) * 0x10101
 				pcb1 := int(src.Cb[pj]) - 128
 				pcr1 := int(src.Cr[pj]) - 128
 				pru := (pyy1 + 91881*pcr1) >> 8
@@ -4823,7 +4823,7 @@ func (z *kernelScaler) scaleX_YCbCr420(tmp [][4]float64, src *image.YCbCr, sr im
 				pj := ((sr.Min.Y+int(y))/2-src.Rect.Min.Y/2)*src.CStride + ((sr.Min.X+int(c.coord))/2 - src.Rect.Min.X/2)
 
 				// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-				pyy1 := int(src.Y[pi]) * 0x10100
+				pyy1 := int(src.Y[pi]) * 0x10101
 				pcb1 := int(src.Cb[pj]) - 128
 				pcr1 := int(src.Cr[pj]) - 128
 				pru := (pyy1 + 91881*pcr1) >> 8
@@ -4870,7 +4870,7 @@ func (z *kernelScaler) scaleX_YCbCr440(tmp [][4]float64, src *image.YCbCr, sr im
 				pj := ((sr.Min.Y+int(y))/2-src.Rect.Min.Y/2)*src.CStride + (sr.Min.X + int(c.coord) - src.Rect.Min.X)
 
 				// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-				pyy1 := int(src.Y[pi]) * 0x10100
+				pyy1 := int(src.Y[pi]) * 0x10101
 				pcb1 := int(src.Cb[pj]) - 128
 				pcr1 := int(src.Cr[pj]) - 128
 				pru := (pyy1 + 91881*pcr1) >> 8
@@ -5759,7 +5759,7 @@ func (q *Kernel) transform_RGBA_YCbCr444_Src(dst *image.RGBA, dr, adr image.Rect
 							pj := (ky-src.Rect.Min.Y)*src.CStride + (kx - src.Rect.Min.X)
 
 							// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-							pyy1 := int(src.Y[pi]) * 0x10100
+							pyy1 := int(src.Y[pi]) * 0x10101
 							pcb1 := int(src.Cb[pj]) - 128
 							pcr1 := int(src.Cr[pj]) - 128
 							pru := (pyy1 + 91881*pcr1) >> 8
@@ -5883,7 +5883,7 @@ func (q *Kernel) transform_RGBA_YCbCr422_Src(dst *image.RGBA, dr, adr image.Rect
 							pj := (ky-src.Rect.Min.Y)*src.CStride + ((kx)/2 - src.Rect.Min.X/2)
 
 							// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-							pyy1 := int(src.Y[pi]) * 0x10100
+							pyy1 := int(src.Y[pi]) * 0x10101
 							pcb1 := int(src.Cb[pj]) - 128
 							pcr1 := int(src.Cr[pj]) - 128
 							pru := (pyy1 + 91881*pcr1) >> 8
@@ -6007,7 +6007,7 @@ func (q *Kernel) transform_RGBA_YCbCr420_Src(dst *image.RGBA, dr, adr image.Rect
 							pj := ((ky)/2-src.Rect.Min.Y/2)*src.CStride + ((kx)/2 - src.Rect.Min.X/2)
 
 							// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-							pyy1 := int(src.Y[pi]) * 0x10100
+							pyy1 := int(src.Y[pi]) * 0x10101
 							pcb1 := int(src.Cb[pj]) - 128
 							pcr1 := int(src.Cr[pj]) - 128
 							pru := (pyy1 + 91881*pcr1) >> 8
@@ -6131,7 +6131,7 @@ func (q *Kernel) transform_RGBA_YCbCr440_Src(dst *image.RGBA, dr, adr image.Rect
 							pj := ((ky)/2-src.Rect.Min.Y/2)*src.CStride + (kx - src.Rect.Min.X)
 
 							// This is an inline version of image/color/ycbcr.go's YCbCr.RGBA method.
-							pyy1 := int(src.Y[pi]) * 0x10100
+							pyy1 := int(src.Y[pi]) * 0x10101
 							pcb1 := int(src.Cb[pj]) - 128
 							pcr1 := int(src.Cr[pj]) - 128
 							pru := (pyy1 + 91881*pcr1) >> 8
diff --git a/draw/stdlib_test.go b/draw/stdlib_test.go
index c45f78c..9015bfd 100644
--- a/draw/stdlib_test.go
+++ b/draw/stdlib_test.go
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
+// +build go1.9
 
 package draw
 
 // This file contains tests that depend on the exact behavior of the
 // image/color package in the standard library. The color conversion formula
-// from YCbCr to RGBA changed between Go 1.4 and Go 1.5, so this file's tests
-// are only enabled for Go 1.5 and above.
+// from YCbCr to RGBA changed between Go 1.4 and Go 1.5, and between Go 1.8 and
+// Go 1.9, so this file's tests are only enabled for Go 1.9 and above.
 
 import (
 	"bytes"
diff --git a/testdata/go-turns-two-down-ab.png b/testdata/go-turns-two-down-ab.png
index 317c3af..ed5a2f6 100644
Binary files a/testdata/go-turns-two-down-ab.png and b/testdata/go-turns-two-down-ab.png differ
diff --git a/testdata/go-turns-two-down-bl.png b/testdata/go-turns-two-down-bl.png
index 597d362..5c8b652 100644
Binary files a/testdata/go-turns-two-down-bl.png and b/testdata/go-turns-two-down-bl.png differ
diff --git a/testdata/go-turns-two-down-cr.png b/testdata/go-turns-two-down-cr.png
index ad1c20a..633354d 100644
Binary files a/testdata/go-turns-two-down-cr.png and b/testdata/go-turns-two-down-cr.png differ
diff --git a/testdata/go-turns-two-down-nn.png b/testdata/go-turns-two-down-nn.png
index 166841a..1debc30 100644
Binary files a/testdata/go-turns-two-down-nn.png and b/testdata/go-turns-two-down-nn.png differ
diff --git a/testdata/go-turns-two-rotate-ab.png b/testdata/go-turns-two-rotate-ab.png
index 04fceaa..a3703a9 100644
Binary files a/testdata/go-turns-two-rotate-ab.png and b/testdata/go-turns-two-rotate-ab.png differ
diff --git a/testdata/go-turns-two-rotate-bl.png b/testdata/go-turns-two-rotate-bl.png
index c8b717e..23105b3 100644
Binary files a/testdata/go-turns-two-rotate-bl.png and b/testdata/go-turns-two-rotate-bl.png differ
diff --git a/testdata/go-turns-two-rotate-cr.png b/testdata/go-turns-two-rotate-cr.png
index 7e5cd9f..d8d9d21 100644
Binary files a/testdata/go-turns-two-rotate-cr.png and b/testdata/go-turns-two-rotate-cr.png differ
diff --git a/testdata/go-turns-two-rotate-nn.png b/testdata/go-turns-two-rotate-nn.png
index 702c863..a5ba282 100644
Binary files a/testdata/go-turns-two-rotate-nn.png and b/testdata/go-turns-two-rotate-nn.png differ
diff --git a/testdata/go-turns-two-up-ab.png b/testdata/go-turns-two-up-ab.png
index 072446d..98e92e2 100644
Binary files a/testdata/go-turns-two-up-ab.png and b/testdata/go-turns-two-up-ab.png differ
diff --git a/testdata/go-turns-two-up-bl.png b/testdata/go-turns-two-up-bl.png
index c1bf630..4a2323d 100644
Binary files a/testdata/go-turns-two-up-bl.png and b/testdata/go-turns-two-up-bl.png differ
diff --git a/testdata/go-turns-two-up-cr.png b/testdata/go-turns-two-up-cr.png
index 0ac8300..1d96033 100644
Binary files a/testdata/go-turns-two-up-cr.png and b/testdata/go-turns-two-up-cr.png differ
diff --git a/testdata/go-turns-two-up-nn.png b/testdata/go-turns-two-up-nn.png
index eb63cb9..93a2806 100644
Binary files a/testdata/go-turns-two-up-nn.png and b/testdata/go-turns-two-up-nn.png differ
diff --git a/testdata/tux-rotate-ab.png b/testdata/tux-rotate-ab.png
index 181966c..d604ec9 100644
Binary files a/testdata/tux-rotate-ab.png and b/testdata/tux-rotate-ab.png differ
diff --git a/testdata/tux-rotate-bl.png b/testdata/tux-rotate-bl.png
index af3f4b0..85b8602 100644
Binary files a/testdata/tux-rotate-bl.png and b/testdata/tux-rotate-bl.png differ
diff --git a/testdata/tux-rotate-cr.png b/testdata/tux-rotate-cr.png
index e5cff31..dbc42ab 100644
Binary files a/testdata/tux-rotate-cr.png and b/testdata/tux-rotate-cr.png differ
diff --git a/testdata/tux-rotate-nn.png b/testdata/tux-rotate-nn.png
index c775c61..0d40c0d 100644
Binary files a/testdata/tux-rotate-nn.png and b/testdata/tux-rotate-nn.png differ