Skip to content
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

OnDiskBitmap: INCOMPATIBLE CHANGE: Allow them to use palettes #4823

Merged
merged 2 commits into from
Jun 1, 2021

Conversation

jepler
Copy link
Member

@jepler jepler commented May 28, 2021

Before, when an OnDiskBitmap was a paletted bitmap type, the palette was internal to the OnDiskBitmap, and it internally performed the palette conversion itself. When using with a tilegrid, a ColorConverter() object always had to be passed.

Now, an OnDiskBitmap has a "pixel_shader" property. If the bitmap is a paletted bitmap type, it is a (modifiable) Palette object. Otherwise, it is a ColorConverter() object as before. This allows palette effects to be applied to paletted OnDiskBitmaps.

Code that used to say:

face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter())

must be updated to say:

face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)

Compatible code for 6.x and 7.x can say

face = displayio.TileGrid(odb, pixel_shader=getattr(odb, 'pixel_shader', ColorConverter())

Closes: #4636. An alternative to #4438 which adds less code and is more general.

Before, when an OnDiskBitmap was a paletted bitmap type, the palette
was internal to the OnDiskBitmap, and it internally performed the palette
conversion itself.  When using with a tilegrid, a ColorConverter() object
always had to be passed.

Now, an OnDiskBitmap has a "pixel_shader" property.  If the bitmap is
a paletted bitmap type, it is a (modifiable) Palette object.  Otherwise,
it is a ColorConverter() object as before. This allows palette effects
to be applied to paletted OnDiskBitmaps.

Code that used to say:
```python
face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter())
```
must be updated to say:
```python
face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
```

Compatible code for 6.x and 7.x can say
```python
face = displayio.TileGrid(odb, pixel_shader=getattr(odb, 'pixel_shader', ColorConverter())
```
@jepler jepler requested a review from tannewt May 28, 2021 15:59
@jepler
Copy link
Member Author

jepler commented May 28, 2021

@tannewt requesting your review since this is an incompatible change.

.. this branch was old and stale, it turns out
Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked it all over and looks good to me. I won't approve until someone else can view the incompatibility part.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! I believe it'll only break indexed on disk bitmaps. non-indexed bitmaps will use ColorConverter regardless.

@tannewt tannewt added this to the 7.0.0 milestone Jun 1, 2021
@tannewt tannewt merged commit a94b8cf into adafruit:main Jun 1, 2021
@jepler
Copy link
Member Author

jepler commented Jun 1, 2021

Thank you!

@ladyada
Copy link
Member

ladyada commented Jul 11, 2021

@jepler @tannewt for breaking changes like these, we need to put a plan in place for who will go through and update all the guides and tutorials. lets chat on monday and come up with a system since there are so many breaking changes in 7.x :)

@tannewt
Copy link
Member

tannewt commented Jul 12, 2021

It's now tracked in #4982 and I've asked @jepler to do the reviews for @lesamouraipourpre on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OnDiskBitmap: add a pixel_shader property
4 participants