cloudhead / rx

👾 Modern and minimalist pixel editor
https://discord.gg/xHggPjfsS9
GNU General Public License v3.0
3.09k stars 109 forks source link

Gif export seems to only export colors in the current palette #73

Open rosemash opened 4 years ago

rosemash commented 4 years ago

Issue: When exporting as a gif, it seems that colors which aren't part of the palette end up not being in the final gif. Those pixels end up transparent or simply the wrong color.

How to reproduce: Open a png file with rx file.png where file.png is an image containing colors that aren't in the starting palette. Split into multiple frames, then export as a gif. Switch to a palette with the required colors, then export as a second gif. The first gif has missing colors, but the second gif is correct.

cloudhead commented 4 years ago

Yeah I'm aware of this behavior. It's tricky to get this exactly right, as gifs have a maximum of 256 colors, while pngs can old millions. In the master branch, there is a command p/sample to load the view colors into the palette. You could run this command before exporting to gif.

I think one potential long term solution is to scan the view buffer for all colors and add them to the gif palette. If there are more than 256, we can throw an error and refuse to export.