-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fast copy from ulab to displayio.Bitmap #4414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Basically, what would be needed is a way of passing the bytes of an ndarray directly into the bitmap. One option would be the The module that has to be modified is most probably this: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/displayio/Bitmap.c The bitmap constructor is defined here circuitpython/shared-module/displayio/Bitmap.c Lines 33 to 47 in 05ed179
so, I believe, one could simply add a
self->data , without allocating any memory.
|
I'm interested in helping out on this and stretching my skills a bit to try to understand better how the bitmap structure is formed and modified. Sorry I didn't chime in during today's CircuitPython call, but I'm not very well versed in the terminology y'all use, so I have to do some digging to be partially intelligible when discussing this. Here goes: As best I understand, to save memory the bitmap structure uses the minimum number of bits necessary to hold the maximum palette indices ( So, the In looking at the I've heard y'all talk about using "buffer protocols" to handle this, but I'm not very familiar with this, and @v923z you mention adding a |
No, that should definitely be done on the bitmap's side.
Bits can't be stored even in
I can only speak for |
Playing with ulab, I found it was costly to copy from an array to a display.bitmap.
ulab can build a buffer: ulab.array.tobytes
Here is the current fastest way I was able to copy:
The text was updated successfully, but these errors were encountered: