Skip to content

Fix for builds without longint #32

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

Merged
merged 2 commits into from
Jun 25, 2020

Conversation

FoamyGuy
Copy link
Contributor

Closes #28

This change refactors negative height check into its own file in order to avoid using 0x7FFFFFFF altogether on builds without longint. This allows it to avoid a seemingly un-catchable overflow error.

I am very open to other ways to achieve this library working on devices without longint and continuing to work correctly with negative height bmp files on builds that do have longint. This was the only thing I managed to come up with that was working.

If you try to use load a negative bmp on a build without longint now you get this error:

code.py output:
Traceback (most recent call last):
  File "code.py", line 7, in <module>
  File "/lib/adafruit_imageload/__init__.py", line 61, in load
  File "/lib/adafruit_imageload/__init__.py", line 52, in load
  File "/lib/adafruit_imageload/bmp/__init__.py", line 57, in load
NotImplementedError: Negative height BMP files are not supported on builds without longint

If you load a negative bmp on a build with longint it will correctly show the image.

These changes were tested on EdgeBadge and PewPew M4 respectively using the image file linked in #18

@FoamyGuy FoamyGuy requested a review from a team June 24, 2020 13:58
@FoamyGuy
Copy link
Contributor Author

It looks like there is still some sort of trouble to sort out with this PR. I just ran into this error with it:

  File "/lib/adafruit_imageload/__init__.py", line 61, in load
  File "/lib/adafruit_imageload/__init__.py", line 52, in load
  File "/lib/adafruit_imageload/bmp/__init__.py", line 76, in load
  File "/lib/adafruit_imageload/bmp/indexed.py", line 83, in load
OverflowError: overflow converting long int to machine word

I will look into it.

@FoamyGuy FoamyGuy removed the request for review from a team June 24, 2020 22:14
@evaherrada evaherrada self-requested a review June 25, 2020 17:11
@evaherrada evaherrada merged commit 0d193cd into adafruit:master Jun 25, 2020
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 26, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP280 to 3.2.2 from 3.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BMP280#25 from FoamyGuy/fix_readme

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.0 from 3.9.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#82 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 0.11.0 from 0.10.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#32 from FoamyGuy/handle_longint_missing_error
  > Revert "refactor negative height check into its own file"
  > refactor negative height check into its own file
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#31 from FoamyGuy/fix_simpletest
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#29 from adafruit/setup-py-disabled
  > build.yml: add black formatting check

Updating https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf to 2.1.0 from 2.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#20 from dunkmann00/rgb-for-rgbw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

negative height check doesn't work without longint
2 participants