Tweak test/data/artif*/gif-transparent-index.gif
diff --git a/script/make-artificial.go b/script/make-artificial.go index 9de99ab..7ebfb13 100644 --- a/script/make-artificial.go +++ b/script/make-artificial.go
@@ -959,7 +959,7 @@ flags := uint8(0) duration := uint32(0) - transparentIndex := uint32(0) + transparentIndex := uint8(0) for s != "" { term := "" if i := strings.IndexByte(s, ' '); i >= 0 { @@ -980,12 +980,12 @@ case term == "animationDisposalRestorePrevious": flags |= 0x0C case strings.HasPrefix(term, trans): - num, remaining, ok := parseNum(term[len(trans):]) - if !ok || remaining != "" { + num, err := strconv.ParseUint(term[len(trans):], 0, 8) + if err != nil { break outer } flags |= 0x01 - transparentIndex = num + transparentIndex = uint8(num) case strings.HasSuffix(term, ms): num, remaining, ok := parseNum(term[:len(term)-len(ms)]) if !ok || remaining != "" { @@ -1002,7 +1002,7 @@ flags, uint8(duration>>0), uint8(duration>>8), - uint8(transparentIndex), + transparentIndex, 0x00, ) return stateGif, nil
diff --git a/test/data/artificial/gif-transparent-index.gif b/test/data/artificial/gif-transparent-index.gif index a9f0e09..471ae7a 100644 --- a/test/data/artificial/gif-transparent-index.gif +++ b/test/data/artificial/gif-transparent-index.gif Binary files differ
diff --git a/test/data/artificial/gif-transparent-index.gif.make-artificial.txt b/test/data/artificial/gif-transparent-index.gif.make-artificial.txt index 96f05c0..61f2ca8 100644 --- a/test/data/artificial/gif-transparent-index.gif.make-artificial.txt +++ b/test/data/artificial/gif-transparent-index.gif.make-artificial.txt
@@ -1,36 +1,67 @@ # Feed this file to script/make-artificial.go +# This GIF image has two frames. The first is 4x2 and contains 8 shades of red. +# The second is 3x1, positioned at (1, 1), and nominally contains 3 shades of +# blue but the middle pixel is transparent. + make gif header image { - imageWidthHeight 4 1 - # Four shades of red and then green, cyan, blue, white. + imageWidthHeight 4 2 + # 16 shades of red and then 16 shades of blue. palette { + 0x00 0x00 0x00 + 0x10 0x00 0x00 + 0x20 0x00 0x00 + 0x30 0x00 0x00 + 0x40 0x00 0x00 + 0x50 0x00 0x00 + 0x60 0x00 0x00 + 0x70 0x00 0x00 + 0x80 0x00 0x00 0x90 0x00 0x00 0xA0 0x00 0x00 0xB0 0x00 0x00 - 0x00 0xC0 0x00 - 0x00 0xD0 0xD0 - 0x00 0x00 0xE0 - 0xF0 0xF0 0xF0 + 0xC0 0x00 0x00 + 0xD0 0x00 0x00 + 0xE0 0x00 0x00 + 0xF0 0x00 0x00 + + 0x00 0x00 0x00 + 0x00 0x00 0x11 + 0x00 0x00 0x22 + 0x00 0x00 0x33 + 0x00 0x00 0x44 + 0x00 0x00 0x55 + 0x00 0x00 0x66 + 0x00 0x00 0x77 + + 0x00 0x00 0x88 + 0x00 0x00 0x99 + 0x00 0x00 0xAA + 0x00 0x00 0xBB + 0x00 0x00 0xCC + 0x00 0x00 0xDD + 0x00 0x00 0xEE + 0x00 0x00 0xFF } } graphicControl animationDisposalNone 100ms frame { - frameLeftTopWidthHeight 0 0 4 1 + frameLeftTopWidthHeight 0 0 4 2 } -lzw 7 0x00 0x01 0x02 0x03 +lzw 7 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F -graphicControl animationDisposalNone 200ms transparentIndex=5 +graphicControl animationDisposalNone 200ms transparentIndex=0x1A frame { - frameLeftTopWidthHeight 0 0 3 1 + frameLeftTopWidthHeight 1 1 3 1 } -lzw 7 0x04 0x05 0x06 +lzw 7 0x1F 0x1A 0x15 trailer