Commit Graph

3 Commits

Author SHA1 Message Date
Jeff Epler ef4623dfae gifio: Add dithered output
It's not a great dither, but we're low on CPU time sooo
2021-10-27 10:54:31 -05:00
Jeff Epler 081f636c17 Fix typing 2021-10-26 08:54:18 -05:00
Jeff Epler c34b6f757f Implement gifio.GifWriter
This involves:
 * Adding a new "L8" colorspace for colorconverters
 * factoring out displayio_colorconverter_convert_pixel
 * Making a minimal "colorspace only" version of displayio for the
   unix port (testing purposes)
 * fixing an error message

I only tested writing B&W animated images, with the following script:
```python
import displayio
import gifio

with gifio.GifWriter("foo.gif", 64, 64, displayio.Colorspace.L8) as g:
    for i in range(0, 256, 14):
        data = bytes([i, 255-i] * 32 + [255-i, i] * 32) * 32
        print("add_frame")
        g.add_frame(data)

# expected to raise an error, buffer is not big enough
with gifio.GifWriter("/dev/null", 64, 64, displayio.Colorspace.L8) as g:
    g.add_frame(bytes([3,3,3]))
```
2021-10-26 08:54:18 -05:00