-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support multi-byte values with Bitmap #1746
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
It also corrects the behavior of single byte values. Fixes micropython#1744
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.
I looked over the logic and it looks good from here!
self->read_only = false; | ||
self->bits_per_value = bits_per_value; | ||
|
||
if (bits_per_value > 8) { | ||
mp_raise_NotImplementedError(translate("Only bit maps of 8 bit color or less are supported")); | ||
if (bits_per_value > 8 && bits_per_value != 16 && bits_per_value != 32) { |
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.
Doesn't this assume that size_t
is uint32_t
?
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.
Also, shouldn't we also be checking that it's a power of two when < 8?
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.
How does it assume uint32_t is size_t?
It's probably better to modify this check to check for 24 bit and fail. We can rely on shared-bindings to do power of two below 8 and multiple of 8 above. I just didn't want to support packing/unpacking 24-bit values.
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.
Well, it actually assumes 32 <= size_t <= 40
. I guess I'm trying to understand why you replaced uint32_t
with size_t
earlier on, when you still hard-code the supported sizes.
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.
I changed it because I was in there and better understand size_t can be used to support 64 bit in the future. Perhaps I should have left it to reduce the diff size.
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.
I see, sorry, I thought it's related.
It also corrects the behavior of single byte values.
Fixes #1744