Commit 4bba6729 authored by Andrew Bonventre's avatar Andrew Bonventre Committed by Nigel Tao

image/gif: set default loop count to 0 when app ext. is not present

It was otherwise not being preserved across
specific Decode->Encode->Decode calls.

Fixes #11287

Change-Id: I40602da7fa39ec67403bed52ff403f361c6171bb
Reviewed-on: https://go-review.googlesource.com/11256Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
parent f2662f2c
......@@ -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
}
......
......@@ -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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment