Skip to content

displayio.Bitmap value_count max should be 65536 not 65535 #8426

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

Closed
rimwolf-redux opened this issue Sep 23, 2023 · 6 comments
Closed

displayio.Bitmap value_count max should be 65536 not 65535 #8426

rimwolf-redux opened this issue Sep 23, 2023 · 6 comments

Comments

@rimwolf-redux
Copy link

rimwolf-redux commented Sep 23, 2023

CircuitPython version

Adafruit CircuitPython 8.2.6 on 2023-09-12; Adafruit Feather M4 Express with samd51j19

Supplying 65536 as the value_count argument to a displayio.Bitmap constructor yields
an error that value must be 1..65535:

>>> import displayio
>>> bitmap = displayio.Bitmap(160, 120, 65536)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: value_count must be 1-65535
>>>

But in a colorspace like RGB565, all 65536 16-bit values are valid. As for user friendliness, all three of the examples in https://github.com/adafruit/Adafruit_CircuitPython_OV7670/blob/main/examples that use displayio.Bitmap supply 65536 as an argument.

The code in https://github.com/adafruit/circuitpython/blob/main/shared-bindings/displayio/Bitmap.c that calculates the bits (per pixel) from the value_count subtracts 1 from the value_count, so correctly yields 16 for 65536 as well as 65535.

Code/REPL

import displayio
bitmap = displayio.Bitmap(160, 120, 65536)

Behavior

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: value_count must be 1-65535

Description

No response

Additional information

Changing the upper limit to 65536 in the definition of value_count in Bitmap.c (line 67 in the current github version) looks like it would resolve this issue.

@jepler
Copy link

jepler commented Sep 25, 2023

I agree! would you be able to submit a pull request to fix this?

@rimwolf-redux
Copy link
Author

It's been some time since I've built CircuitPython, but I can give it a shot. This should be against 8.2.x (git checkout 8.2.x) I guess?

@tannewt
Copy link
Member

tannewt commented Sep 25, 2023

It's been some time since I've built CircuitPython, but I can give it a shot. This should be against 8.2.x (git checkout 8.2.x) I guess?

Yes please. That way it'll get into a stable release more quickly. (We periodically merge it back to main too.)

@rimwolf-redux
Copy link
Author

Submitted PR #8434 to fix this issue.

@isacben
Copy link

isacben commented Oct 9, 2023

I think this issue is solved. ?

@dhalbert
Copy link
Collaborator

dhalbert commented Oct 9, 2023

Fixed by #8434. Because the PR was not on main, this issue was not closed when that PR was merged.

@dhalbert dhalbert closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants