Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picdocument: fix rendering of animated GIFs #653

Merged
merged 2 commits into from
Apr 19, 2018

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Apr 19, 2018

pic.lua was returning each frame as-is. Very often, frames are just a mask to apply on previous frame, so we need to combine them and paste each one over the previous.
Adds support for transparency for that, and limited support for the rare other "dispose" modes of the GIF spec.

This makes the little (or full size) animated territories expansion maps (gray backround with a year displayed) found on these Wikipedia pages, when saved as a GIF, correctly displayed by PicDocument:
https://fr.wikipedia.org/wiki/Empire_romain https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Roman_Republic_Empire_map.gif/220px-Roman_Republic_Empire_map.gif
https://fr.wikipedia.org/wiki/Saint-Empire_romain_germanique https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/HRR.gif/220px-HRR.gif
https://fr.wikipedia.org/wiki/Empire_byzantin https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Byzantine_Empire_animated.gif/220px-Byzantine_Empire_animated.gif

(Needs to clear cache if comparing previous/after.)

I was thinking about adding support for such animated GIF in ImageViewer (so we can view them from Wikipedia saved as EPUB), but I first had to see how they work. MuPDF (used to render images) has no support for multi-frames images. Had to have a look a ffi/pic.lua which uses giflib, that does have support for them. So I just fixed the handling of these animated gif in pic.lua, even if I guess hardly nobody uses that feature.

pic.lua was returning each frame as-is. Very often, frames
are just a mask to apply on previous frame, so we need to combine
them and paste each one over the previous.
Adds support for transparency for that, and limited support
for the rare other "dispose" modes of the GIF spec.
@poire-z poire-z merged commit 3bdb32a into koreader:master Apr 19, 2018
@poire-z poire-z deleted the animated_gif branch April 19, 2018 14:47
Frenzie added a commit to Frenzie/koreader that referenced this pull request Apr 20, 2018
Includes:
* picdocument: fix rendering of animated GIFs koreader/koreader-base#653
* [build] Some minor build tweaks koreader/koreader-base#651
* [chore, CI] Update to latest Docker images koreader/koreader-base#654
* [chore, Kobo] Deprecate Kobo always UTF8Filename() patch koreader/koreader-base#655 (upstream integrated workaround for koreader#542 previous fix in koreader#3845)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants