Getting the first frame of a GIF image without dow

2020-06-12 04:52发布

I would like to get a GIF image from the network, but I found that if I download the whole GIF image, it would cause a lot of network traffic.

Can I get only the first frame of a GIF image without downloading all the other frames?

标签: java android gif
1条回答
Rolldiameter
2楼-- · 2020-06-12 05:33

Well, I haven't found ready-to-use solution, but you can do this way (it'll lead to some "low-level" tricks):

Following wiki about GIFs, animated gif files can be splitted into frames, and end of frame can be easily recognized. So, you'll need to read GIF header, screen information, information about animation into buffer, download first frame and append information like GIF is ended ("3B" following wiki article). And, if you copy this data into separate bufer, you'll be able to continue whole file downloading without re-downloading first frame.

Also you can edit header information to format first frame into static gif.

查看更多
登录 后发表回答