-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
extmod/framebuf: Add "remap" option to blit #3238
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
Conversation
b7e7c3d
to
22836a2
Compare
Add an optional keyword argument "remap" to the framebuf.blit method, which allows to pass an array specifying the color palette to be used for mapping the colors while blitting. This makes it possible to blit between framebufs with different color depths, and also to do palette effects.
I added the docs and a simple test. |
Is there anything else that needs to be done here? |
Overall the idea is good, thanks. Considering code size: it might be more compact to use positional args rather than have a full array of allowed args. If it's positional then you need to specify "key" if you want to specify "remap", but you can just pass -1 for key if you don't want to use that feature. How about making the remap argument something with the buffer protocol (eg bytes, bytearray), rather than a list/tuple? Using a buffer object would allow much more compact mappings and allow them to be stored in ROM. |
Not sure what you mean with list/tuple. 8000 I used array of ints, because that seems to fit the color data type best. How would bytes/bytearray work? Take two bytes for every color? |
Oh, I see I have a list in the test, not an array — I guess it's getting converted? I'm not sure how this all works internally in MicroPython, to be honest. |
The I'd suggest converting this to |
Add Bastwifi by Electronic Cats
Add an optional keyword argument "remap" to the framebuf.blit method,
which allows to pass an array specifying the color palette to be used
for mapping the colors while blitting. This makes it possible to blit
between framebufs with different color depths, and also to do palette
effects.