cosmopolitan/dsp
William Chargin 4a1419fefa
ttyraster: restore colors at start of each line (#471)
The patch in #469 was buggy for images where the start of a row matched
the end of the previous row. We don't re-issue the `setbgfg` ANSI codes
when we think that the color hasn't changed. But by sending an `\e[0m`
sequence at the end of the line without updating `bg` or `fg`, we
desynced `bg` and `fg` from the actual ANSI state. Now, we simply follow
that line-terminating `\e[0m` with another `setbgfg` call.

This bug was visible in images with a constant-color matte border:

![Screenshot of `printimage` output before and after this commit when
run on `lemurs.png` and `lemursborder.png`, where `lemursborder.png` has
a thick blue border around the outside of the image. Both versions look
fine for `lemurs.png`. For `lemursborder.png`, the "before" version has
a chess board pattern for the left border (except for the first row) and
the bottom border. The "after" version looks correct.][ss]

[ss]: https://user-images.githubusercontent.com/4317806/178120511-c1b89348-2376-4bf2-a2d3-8723d2663bd4.png

Fixes: 85aecbda67 ("ttyraster: reset ANSI attributes after each line (#469)")
wchargin-branch: ttyraster-restore-each-line
wchargin-source: 621a788cfa0a87ce360e142a6004e325cca70caa
2022-07-09 16:47:42 -07:00
..
bmp Fix link order in cosmopolitan.a 2021-01-16 12:05:41 -08:00
core Clean old .source directive out of asm code 2022-03-18 12:43:21 -07:00
mpeg Clean old .source directive out of asm code 2022-03-18 12:43:21 -07:00
scale Make improvements 2022-03-16 13:40:10 -07:00
tty ttyraster: restore colors at start of each line (#471) 2022-07-09 16:47:42 -07:00
dsp.mk Initial import 2020-06-15 07:18:57 -07:00