Closed Julyyq closed 9 years ago
Not supported by canvas
For a while, chrome would draw GIFs animated on the canvas, but the spec says to only draw the first frame. If you need to draw animated GIFs on the canvas, you can use a library that will parse GIFs. If you just want to playback the frames such as to preview the GIF, you can handle that yourself by keeping ImageData objects or canvases.
@1j01 Thanks for your reply.I saw a library called fabricjs that draw animated images on canvas, but with using sprites, it's unconvince. I think it's painful to draw aniamated image onto canvas now.
@Julyyq Have you tried libgif.js? Looks like you should be able to set auto_play
and it should animate a GIF onto a canvas you give it.
@1j01 libgif tries to draw gif into canvas which is inside in a iframe, that is, I can't specific the canvas that I wanna draw in. And, Its propose is to make gif rubbable and plays like a video. Anyway, the library tells me that gif could be draw into canvas with some work-around.
@Julyyq Yeah, that library doesn't really live up to its name. Maybe readwrite-gif instead? Both libraries it uses have both encoders and decoders, but neither jsgif nor omggif have documentation, so I guess readwrite-gif is an attempt at giving some kind of API to them, although I'm not sure why it uses both...
Only first frame is shown, does canvas not support drawing gif ? Or, there's a bug within the generated gif ? Thanks very much.