spillerrec / imgviewer

Customizable image viewer with minimalistic interface
2 stars 1 forks source link

Can we get GIF to stay paletted #46

Open spillerrec opened 8 years ago

spillerrec commented 8 years ago

The color conversion is not optimized for animations, as this would require it to keep a copy of each frame, causing quite an increase in memory consumption. However converting the colors for each frame is quite CPU intensive. But most animated images are GIFs, and GIF is a paletted format. Just converting the palette is much faster, and if it does not require to merge sub-parts, it should be possible to keep it that way.

But Qt appears to convert it to RGB, ruining this. Maybe it is worth looking into creating our own GIF reader, and potentially reuse the merging code for PNG (even though palettes are less common)?

spillerrec commented 7 years ago

From the small sample I tested so far, over 90% of them stays indexed. Half of those where the color table changed the entire image was updated, so by checking for that we could just skip the merging altogether. Should be nice for performance as well, so it is enabled even when the color table matches. But it seems it often fails for shared tables, since it contains the transparency entry, but do not actually use it.

Current bugs: completely transparent GIFs are not transparent due to its color palette not updating.