mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Decode multiple graphic controls in a GIF
This commit is contained in:
1 parent
5bea867f72
commit
b1ff27fded
6 files changed
+89
-16
No files matched your search
@@ -513,9 +513,10 @@ var gifGlobals struct {
|
||||
|
||||
func stateGif(line string) (stateFunc, error) {
|
||||
const (
|
||||
cmdB = "bytes "
|
||||
cmdL = "lzw "
|
||||
cmdLC = "loopCount "
|
||||
cmdB = "bytes "
|
||||
cmdGCD = "graphicControlDuration "
|
||||
cmdL = "lzw "
|
||||
cmdLC = "loopCount "
|
||||
)
|
||||
outer:
|
||||
switch {
|
||||
@@ -547,6 +548,25 @@ outer:
|
||||
}
|
||||
return stateGif, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdGCD):
|
||||
s := line[len(cmdGCD):]
|
||||
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.
|
||||
out = append(out,
|
||||
0x21, 0xF9, 0x04, 0x00,
|
||||
uint8(duration>>0),
|
||||
uint8(duration>>8),
|
||||
0x00, 0x00,
|
||||
)
|
||||
return stateGif, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdL):
|
||||
s := line[len(cmdL):]
|
||||
litWidth, s, ok := parseNum(s)
|
||||
|
||||
Reference in new issue
Block a user