-
Notifications
You must be signed in to change notification settings - Fork 1.3k
OnDiskBitmap palette getter/setters #4438
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just have a Palette
object available as .palette
instead? That would allow for transparency and such.
In fact, maybe we should switch to returning the pixel index here so that it's truly a value. Then TileGrid could map that to a color with its pixel_shader (like odb.palette).
@@ -3950,6 +3966,10 @@ msgstr "" | |||
msgid "syntax error in uctypes descriptor" | |||
msgstr "" | |||
|
|||
#: shared-module/displayio/OnDiskBitmap.c | |||
msgid "this OnDiskBitmap is raw color, not indexed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unify this with the similar message above.
To be perfectly honest I couldn’t decipher the syntax to make something act as a As for whether it should be redefined as a normal palette object, I’m not sure I understand how this OnDiskBitmap works with ColorConverter, so I’m unsure if making it into a palette object will cause other issues. But I speculate that this OnDiskBitmap was designed primarily for non-color-indexed bitmaps, so a palette is only warranted for the indexed flavor. Maybe it should only create a palette for indexed bitmaps, but then ColorConverter will have to be modified to take a Palette object. Your suggestions and clarifications are welcome. |
Sure! The key thing is that there is an intermediate "property" object that stores pointers to the getter and setter functions. See: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/digitalio/DigitalInOut.c#L224 (This is how properties work internally.)
Yup, I think
You don't need ColorConverter if you have a Palette. ColorConverter is just there to change 24 bit "values" (aka colors) into 16 bit colors. Palette does this conversion already internally for its 24 bit colors. The main change I think is: https://github.com/adafruit/circuitpython/blob/main/shared-module/displayio/OnDiskBitmap.c#L159 It should return the index and then the external palette can map it. |
Interesting |
@jepler I think your work will supercede or obsolete this PR. I'll close this one for now and await to see if your additions also provide this capability. |
This is an addition to add color palette getters/setters for the OnDiskBitmap. This will allow for palete animations/color cycling for bitmaps without having to load them into RAM.
Also, this adds a flag that provides an option to force refresh of an OnDiskBitmap whenever the palette is modified.
This work was spurred out of an exploration of animated icons. @FoamyGuy demonstrated that using OnDiskBitmap allowed loading of significantly more images for the "TouchDeck" project, however currently there is no way of adjusting the color palette. This addition allows modifications of an OnDiskBitmap's color palette to achieve these types of color cycling animations.
This capability probably has a relative small set of use cases, so if feedback is that this should be put on hold, I'm perfectly fine to park this one, and it will reside here for posterity.
This allows OnDiskBitmap to do these kinds of palette animations:
