mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Move num_loops out of the image_config
For the GIF format, it isn't necessarily before the first frame.
This commit is contained in:
1 parent
36fd9cfd31
commit
7be9c39283
10 files changed
+187
-65
No files matched your search
@@ -502,7 +502,8 @@ var gifGlobals struct {
|
||||
|
||||
func stateGif(line string) (stateFunc, error) {
|
||||
const (
|
||||
cmdL = "lzw "
|
||||
cmdL = "lzw "
|
||||
cmdLC = "loopCount "
|
||||
)
|
||||
outer:
|
||||
switch {
|
||||
@@ -562,6 +563,27 @@ outer:
|
||||
}
|
||||
out = append(out, 0x00)
|
||||
return stateGif, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdLC):
|
||||
s := line[len(cmdLC):]
|
||||
loopCount, _, ok := parseNum(s)
|
||||
if !ok || 0xFFFF < loopCount {
|
||||
break
|
||||
}
|
||||
out = append(out,
|
||||
0x21, // Extension Introducer.
|
||||
0xFF, // Application Extension Label.
|
||||
0x0B, // Block Size.
|
||||
)
|
||||
out = append(out, "NETSCAPE2.0"...)
|
||||
out = append(out,
|
||||
0x03, // Block Size.
|
||||
0x01, // Magic Number.
|
||||
byte(loopCount),
|
||||
byte(loopCount>>8),
|
||||
0x00, // Block Terminator.
|
||||
)
|
||||
return stateGif, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("bad stateGif command: %q", line)
|
||||
|
||||
Reference in new issue
Block a user