Closed clort81 closed 2 years ago
Currently on mobile and can't test this out. Understand the code but afraid of some feature issues/bugs. Can you please give me an example of an image, let's say, the github logo, ran through your edited script? Plus, if you'd want it, you can open it in a PR.
There are already checks whether fg/bg colors are different in emit_image:
if (x == 0 || charData.bgColor != lastCharData.bgColor)
emit_color(flags | FLAG_BG, charData.bgColor[0], charData.bgColor[1], charData.bgColor[2]);
if (x == 0 || charData.fgColor != lastCharData.fgColor)
emit_color(flags | FLAG_FG, charData.fgColor[0], charData.fgColor[1], charData.fgColor[2]);
Both rendering time and filesize can be reduced by not emitting colors for a character when they haven't changed from the previous character. Also space characters don't need a foreground color set.
This saves me about 3-75% in filesize, depending on image:
This is just WorksForMe code, but a real programmer should understand what is intended.