mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Add graphicControl disposal to make-artificial
This commit is contained in:
1 parent
fc9c2916f5
commit
6700c721c7
3 files changed
+35
-14
No files matched your search
@@ -527,10 +527,10 @@ var gifGlobals struct {
|
||||
|
||||
func stateGif(line string) (stateFunc, error) {
|
||||
const (
|
||||
cmdB = "bytes "
|
||||
cmdGCD = "graphicControlDuration "
|
||||
cmdL = "lzw "
|
||||
cmdLC = "loopCount "
|
||||
cmdB = "bytes "
|
||||
cmdGC = "graphicControl "
|
||||
cmdL = "lzw "
|
||||
cmdLC = "loopCount "
|
||||
)
|
||||
outer:
|
||||
switch {
|
||||
@@ -562,8 +562,26 @@ outer:
|
||||
}
|
||||
return stateGif, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdGCD):
|
||||
s := line[len(cmdGCD):]
|
||||
case strings.HasPrefix(line, cmdGC):
|
||||
s := line[len(cmdGC):]
|
||||
|
||||
flags := uint8(0)
|
||||
if i := strings.IndexByte(s, ' '); i < 0 {
|
||||
break
|
||||
} else {
|
||||
switch s[:i] {
|
||||
case "animationDisposalNone":
|
||||
flags |= 0x00
|
||||
case "animationDisposalRestoreBackground":
|
||||
flags |= 0x08
|
||||
case "animationDisposalRestorePrevious":
|
||||
flags |= 0x0C
|
||||
default:
|
||||
break outer
|
||||
}
|
||||
s = s[i+1:]
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(s, "ms") {
|
||||
break
|
||||
}
|
||||
@@ -573,11 +591,16 @@ outer:
|
||||
break
|
||||
}
|
||||
duration /= 10 // GIF's unit of time is 10ms.
|
||||
|
||||
transparentIndex := uint8(0)
|
||||
|
||||
out = append(out,
|
||||
0x21, 0xF9, 0x04, 0x00,
|
||||
0x21, 0xF9, 0x04,
|
||||
flags,
|
||||
uint8(duration>>0),
|
||||
uint8(duration>>8),
|
||||
0x00, 0x00,
|
||||
transparentIndex,
|
||||
0x00,
|
||||
)
|
||||
return stateGif, nil
|
||||
|
||||
|
||||
@@ -17,16 +17,14 @@ image {
|
||||
|
||||
loopCount 1
|
||||
|
||||
# TODO: graphicControl animationDisposalRestoreBackground 100ms
|
||||
bytes 0x21 0xF9 0x04 0x08 0x0A 0x00 0x00 0x00
|
||||
graphicControl animationDisposalRestoreBackground 100ms
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 0 0 2 1
|
||||
}
|
||||
lzw 2 0x00 0x01
|
||||
|
||||
# TODO: graphicControl animationDisposalRestoreBackground 200ms
|
||||
bytes 0x21 0xF9 0x04 0x08 0x14 0x00 0x00 0x00
|
||||
graphicControl animationDisposalRestoreBackground 200ms
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 2 0 1 1
|
||||
|
||||
@@ -20,8 +20,8 @@ image {
|
||||
}
|
||||
}
|
||||
|
||||
graphicControlDuration 200ms
|
||||
graphicControlDuration 300ms
|
||||
graphicControl animationDisposalNone 200ms
|
||||
graphicControl animationDisposalNone 300ms
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 0 0 1 1
|
||||
|
||||
Reference in new issue
Block a user