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

commitf315e440302883054d0c2bd85486878cb4f8572c
parentf3a9b89b59
authormonkeybutter <[email protected]>
date2018-04-03 11:08
tiff: fixes problem with decoding tiled uint16 tiff files.

The proposed fix updates the x axis offset variable in case the tile
surpasses the limits of the destination image.

Fixes golang/go#24657

Change-Id: I6bc52274a05dc41b058f6a6f1d0a304f1b20152d
Reviewed-on: https://go-review.googlesource.com/104295
Reviewed-by: Brad Fitzpatrick <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>

 tiff/reader.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tiff/reader.go b/tiff/reader.go
index 0e3d332..8a941c1 100644
--- a/tiff/reader.go
+++ b/tiff/reader.go
@@ -264,6 +264,9 @@ func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error {
 					}
 					img.SetGray16(x, y, color.Gray16{v})
 				}
+				if rMaxX == img.Bounds().Max.X {
+					d.off += 2 * (xmax - img.Bounds().Max.X)
+				}
 			}
 		} else {
 			img := dst.(*image.Gray)