Skip to content

Commit

Permalink
tiff: don't apply the 8 bps predictor to a 1 bps image.
Browse files Browse the repository at this point in the history
Change-Id: I112fc7189f8afdd54b96562e1989f9fca1d24d68
Reviewed-on: https://go-review.googlesource.com/11135
Reviewed-by: Benny Siegert <[email protected]>
Reviewed-by: Nigel Tao <[email protected]>
  • Loading branch information
yi-ge3 committed Mar 13, 2022
1 parent 7cde6eb commit 0ab6040
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tiff/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error {
// In this case, p contains the color difference to the preceding pixel.
// See page 64-65 of the spec.
if d.firstVal(tPredictor) == prHorizontal {
if d.bpp == 16 {
switch d.bpp {
case 16:
var off int
n := 2 * len(d.features[tBitsPerSample]) // bytes per sample times samples per pixel
for y := ymin; y < ymax; y++ {
Expand All @@ -231,7 +232,7 @@ func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error {
off += 2
}
}
} else {
case 8:
var off int
n := 1 * len(d.features[tBitsPerSample]) // bytes per sample times samples per pixel
for y := ymin; y < ymax; y++ {
Expand All @@ -244,6 +245,8 @@ func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error {
off++
}
}
case 1:
return UnsupportedError("horizontal predictor with 1 BitsPerSample")
}
}

Expand Down

0 comments on commit 0ab6040

Please sign in to comment.