mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add test/data/artificial/gif-transparent-index.gif
This commit is contained in:
1 parent
178c6422b7
commit
344123b179
3 files changed
+68
-21
No files matched your search
+32
-21
@@ -958,40 +958,51 @@ outer:
|
||||
s := line[len(cmdGC):]
|
||||
|
||||
flags := uint8(0)
|
||||
if i := strings.IndexByte(s, ' '); i < 0 {
|
||||
break
|
||||
} else {
|
||||
switch s[:i] {
|
||||
case "animationDisposalNone":
|
||||
duration := uint32(0)
|
||||
transparentIndex := uint32(0)
|
||||
for s != "" {
|
||||
term := ""
|
||||
if i := strings.IndexByte(s, ' '); i >= 0 {
|
||||
term, s = s[:i], s[i+1:]
|
||||
} else {
|
||||
term, s = s, ""
|
||||
}
|
||||
|
||||
const (
|
||||
ms = "ms"
|
||||
trans = "transparentIndex="
|
||||
)
|
||||
switch {
|
||||
case term == "animationDisposalNone":
|
||||
flags |= 0x00
|
||||
case "animationDisposalRestoreBackground":
|
||||
case term == "animationDisposalRestoreBackground":
|
||||
flags |= 0x08
|
||||
case "animationDisposalRestorePrevious":
|
||||
case term == "animationDisposalRestorePrevious":
|
||||
flags |= 0x0C
|
||||
case strings.HasPrefix(term, trans):
|
||||
num, remaining, ok := parseNum(term[len(trans):])
|
||||
if !ok || remaining != "" {
|
||||
break outer
|
||||
}
|
||||
flags |= 0x01
|
||||
transparentIndex = num
|
||||
case strings.HasSuffix(term, ms):
|
||||
num, remaining, ok := parseNum(term[:len(term)-len(ms)])
|
||||
if !ok || remaining != "" {
|
||||
break outer
|
||||
}
|
||||
duration = num / 10 // GIF's unit of time is 10ms.
|
||||
default:
|
||||
break outer
|
||||
}
|
||||
s = s[i+1:]
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(s, "ms") {
|
||||
break
|
||||
}
|
||||
s = s[:len(s)-2]
|
||||
duration, s, ok := parseNum(s)
|
||||
if !ok || s != "" {
|
||||
break
|
||||
}
|
||||
duration /= 10 // GIF's unit of time is 10ms.
|
||||
|
||||
transparentIndex := uint8(0)
|
||||
|
||||
out = append(out,
|
||||
0x21, 0xF9, 0x04,
|
||||
flags,
|
||||
uint8(duration>>0),
|
||||
uint8(duration>>8),
|
||||
transparentIndex,
|
||||
uint8(transparentIndex),
|
||||
0x00,
|
||||
)
|
||||
return stateGif, nil
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 89 B |
@@ -0,0 +1,36 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
make gif
|
||||
|
||||
header
|
||||
|
||||
image {
|
||||
imageWidthHeight 4 1
|
||||
# Four shades of red and then green, cyan, blue, white.
|
||||
palette {
|
||||
0x80 0x00 0x00
|
||||
0x90 0x00 0x00
|
||||
0xA0 0x00 0x00
|
||||
0xB0 0x00 0x00
|
||||
0x00 0xC0 0x00
|
||||
0x00 0xD0 0xD0
|
||||
0x00 0x00 0xE0
|
||||
0xF0 0xF0 0xF0
|
||||
}
|
||||
}
|
||||
|
||||
graphicControl animationDisposalNone 100ms
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 0 0 4 1
|
||||
}
|
||||
lzw 7 0x00 0x01 0x02 0x03
|
||||
|
||||
graphicControl animationDisposalNone 200ms transparentIndex=5
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 0 0 3 1
|
||||
}
|
||||
lzw 7 0x04 0x05 0x06
|
||||
|
||||
trailer
|
||||
Reference in new issue
Block a user