Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #51 and originally stemmed from #4831
These changes begin the process of adding support for BytesIO (and possibly other "file-like" objects).
In order to achieve full support for this on modern versions we will need to modify bitmap.readinto() in the core to be able to work with file-like objects.
I was able to successfully test this using the python readinto code from here:
Adafruit_CircuitPython_ImageLoad/adafruit_imageload/bmp/indexed.py
Line 118 in 681a604
For the purposes of testing I just modified the if statement to force it to use the python readinto code instead of the core bitmaptools.readinto(). My test was run on a FunHouse with
7.0.0-alpha.3
and it did show the downloaded image.As-is in the core this line ends up raising a TypeError:
https://github.com/adafruit/circuitpython/blob/5f81f9ed1cb9ba98436ebdc54756ef1702681703/shared-bindings/bitmaptools/__init__.c#L479
So for full support we'll need to modify that check and the code that comes after it to be okay with accepting a BytesIO object instead of a file. I poked around with this for a bit, but the C code in question is a bit beyond my capabilities at this point. @jepler I think you may have written this function originally do you have any thoughts on whether it would be possible to modify it to accept BytesIO in addition to file type objects?