mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-17 11:16:30 -07:00
Fix animation timing
The timing of the final animation frame wasn't being recorded correctly.
This commit is contained in:
parent
1c4bc9fe39
commit
7430f2cbfa
1 changed files with 8 additions and 7 deletions
|
|
@ -21,8 +21,8 @@ import "C"
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
"image"
|
"image"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -82,7 +82,9 @@ func (ae *AnimationEncoder) AddFrame(img image.Image, duration time.Duration) er
|
||||||
return errors.New("unsupported image type")
|
return errors.New("unsupported image type")
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp := C.int((duration + ae.duration) / time.Millisecond)
|
timestamp := C.int(ae.duration / time.Millisecond)
|
||||||
|
ae.duration += duration
|
||||||
|
|
||||||
if C.WebPAnimEncoderAdd(ae.c, pic, timestamp, nil) == 0 {
|
if C.WebPAnimEncoderAdd(ae.c, pic, timestamp, nil) == 0 {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Encoding error: %d - %s",
|
"Encoding error: %d - %s",
|
||||||
|
|
@ -91,7 +93,6 @@ func (ae *AnimationEncoder) AddFrame(img image.Image, duration time.Duration) er
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ae.duration += duration
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue