Commit Graph

19 Commits

Author SHA1 Message Date
Jeff Epler 774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Dan Halbert 2171e67c1b merge latest adafruit/main 2023-08-13 19:43:54 -04:00
Dan Halbert fe0e2f13bc wip; fix qstr processing 2023-08-10 20:06:32 -04:00
Dan Halbert 0d2c3c3f08 wip: continuing compilation fixes; mp_obj_alloc everywhere 2023-08-07 20:45:57 -04:00
Dan Halbert 1f2a1a6e78 Improve OnDiskGif doc; check image width 2023-06-22 14:24:48 -04:00
gamblor21 afae39765f PR review fixups 2023-04-20 18:26:04 -05:00
gamblor21 403ea89d57 Initial paletts for OnDiskGif 2023-04-18 19:44:03 -05:00
gamblor21 e993d0f3c3 Missing brace 2023-03-22 20:19:09 -05:00
gamblor21 07e83674c9 Add deinit to displayio.Bitmap 2023-03-22 19:20:20 -05:00
gamblor21 8b9f5e7f53 Remove del obj and add deinited 2023-03-22 19:20:20 -05:00
Dan Halbert bac1a9625a OnDiskGif delay was being chopped to 8 bits 2023-03-02 16:47:07 -05:00
gamblor21 cab38ed6a6 Doc fixes and renamed play_frame to next_frame 2023-02-12 11:51:23 -06:00
gamblor21 0c95e6a08e Moving to gifio module 2023-02-12 11:17:34 -06:00
Jeff Epler f4e68e8fae
use mp_get_stream_raise, it's more specific 2021-11-20 08:53:04 -05:00
Jeff Epler e733876574 dither in x/y, not i/j
The easiest thing to implement was to use the i/j numbers, but they were not
directly related to image x/y coordinates.  This may slow things down a tiny
little bit, but it looks much better.
2021-10-27 16:52:56 -05:00
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 dc00226143 gifio: write block data directly into output buffer 2021-10-27 09:38:07 -05:00
Jeff Epler 7d6ac96001 GifWriter: improve efficiency
* Increase colorspace conversion efficiency.
   This not only avoids a function call, it avoids the time-consuming
   switch statement in conver_pixel (replacing it with a single
   conditional on the byteswap flag + accounting for BGR/RGB during
   palette creation)

 * Buffer all the bytes of a single frame together.  By reducing
   low level write calls we get a decent speed increase even though
   it increases data-shuffling a bit.

Together with some other changes that enable "double buffered" camera
capture, this gets me to 8.8fps capturing QVGA (320x240) gifs and
11fps capturing 240x240 square gifs.
2021-10-26 11:11:28 -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