-
Notifications
You must be signed in to change notification settings - Fork 21
Simplify load and use [] on the bitmap #7
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
Tested with the 3 BMPs in this repo's example folder - worked. Loaded and displayed correctly. Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-beta.6 on 2019-03-30; Adafruit PyPortal with samd51j20
>>> import board
>>> import displayio
>>> import adafruit_imageload
>>> group = displayio.Group()
>>> board.DISPLAY.show(group)
>>> image, palette = adafruit_imageload.load("/1bit.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)
>>> tg = displayio.TileGrid(image, pixel_shader=palette)
>>> group.append(tg)
>>> However, try same with this BMP: |
@caternuson I don't crash with an equivalent code.py. I get:
Do you get a safe mode with Beta 7? |
Sorry, forgot that I had rotated the image in gimp. I probably changed it to indexed at the same time. So was not working with that exact BMP that I linked. I do get the same thing you get if I try the original file. Here's the actual file I was using: Just tested this again with beta 7 and guess what - it works! Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-beta.7 on 2019-04-13; Adafruit PyPortal with samd51j20
>>> import board
>>> import displayio
>>> import adafruit_imageload
>>> group = displayio.Group()
>>> board.DISPLAY.show(group)
>>> image, palette = adafruit_imageload.load("/purple.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)
>>> tg = displayio.TileGrid(image, pixel_shader=palette)
>>> group.append(tg)
>>> |
@tannewt I'd say it's working... |
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.
Tested and works. Looks good.
Looks like the red and blue channels are getting swapped. import board
import displayio
import adafruit_imageload
display = board.DISPLAY
bitmap, palette = adafruit_imageload.load("/color_test.bmp",
bitmap=displayio.Bitmap,
palette=displayio.Palette)
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
group = displayio.Group()
group.append(tile_grid)
display.show(group)
while True:
pass |
to show the complete color wheel.
…uit_CircuitPython_ImageLoad into use_bitmap_subscr
Use bitmap subscr
Ok, this now includes a fix for the color order. |
color_depth = int.from_bytes(file.read(2), 'little') | ||
file.seek(46) | ||
colors = int.from_bytes(file.read(4), 'little') | ||
|
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.
These values all look correct to the spec.
Suggestion (no change needed):
It might be easier to maintain and check this section if the seek values are given in hex, so they match up with the documentation.
file.seek(0x12) # Width of the bitmap in pixels
file.seek(0x1C) # Number of bits per pixel
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.
This looks all fine.
Updating https://github.com/adafruit/Adafruit_CircuitPython_CharLCD to 3.2.1 from 3.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_CharLCD#39 from caternuson/iss36 Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735 to 1.0.2 from 1.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_ST7735#5 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735R to 1.0.2 from 1.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_ST7735R#6 from makermelissa/master Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 1.0.2 from 1.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#3 from brentru/patch-return-message Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 0.9.1 from 0.8.1: > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#14 from tannewt/move_tests > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#12 from crookedstorm/feature-tests > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#13 from matt-land/bugfix-fix-the-build-sphinx > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#7 from tannewt/use_bitmap_subscr > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#11 from crookedstorm/docs-add-development-guide Updating https://github.com/adafruit/Adafruit_CircuitPython_Motor to 2.0.0 from 1.5.1: > Merge pull request adafruit/Adafruit_CircuitPython_Motor#30 from adafruit/revert-29-master
No description provided.