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