Skip to content

Commit

Permalink
image/gif: set default loop count to 0 when app ext. is not present
Browse files Browse the repository at this point in the history
It was otherwise not being preserved across
specific Decode->Encode->Decode calls.

Fixes #11287

Change-Id: I40602da7fa39ec67403bed52ff403f361c6171bb
Reviewed-on: https://go-review.googlesource.com/11256
Reviewed-by: Nigel Tao <nigeltao@golang.org>
  • Loading branch information
andybons authored and nigeltao committed Jun 23, 2015
1 parent f2662f2 commit 4bba672
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/image/gif/reader.go
Expand Up @@ -271,7 +271,6 @@ func (d *decoder) readHeaderAndScreenDescriptor() error {
}
}
// d.tmp[12] is the Pixel Aspect Ratio, which is ignored.
d.loopCount = -1
return nil
}

Expand Down
21 changes: 21 additions & 0 deletions src/image/gif/reader_test.go
Expand Up @@ -253,3 +253,24 @@ func TestPixelOutsidePaletteRange(t *testing.T) {
try(t, b.Bytes(), want)
}
}

func TestLoopCount(t *testing.T) {
data := []byte("GIF89a000\x00000,0\x00\x00\x00\n\x00" +
"\n\x00\x80000000\x02\b\xf01u\xb9\xfdal\x05\x00;")
img, err := DecodeAll(bytes.NewReader(data))
if err != nil {
t.Fatal("DecodeAll:", err)
}
w := new(bytes.Buffer)
err = EncodeAll(w, img)
if err != nil {
t.Fatal("EncodeAll:", err)
}
img1, err := DecodeAll(w)
if err != nil {
t.Fatal("DecodeAll:", err)
}
if img.LoopCount != img1.LoopCount {
t.Errorf("loop count mismatch: %d vs %d", img.LoopCount, img1.LoopCount)
}
}

0 comments on commit 4bba672

Please sign in to comment.