Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 15 commits into from
May 14, 2019

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Apr 12, 2019

No description provided.

@caternuson
Copy link
Contributor

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:
https://learn.adafruit.com/assets/49595
and it went into safemode.

@tannewt tannewt self-assigned this Apr 13, 2019
@tannewt
Copy link
Member Author

tannewt commented Apr 17, 2019

@caternuson I don't crash with an equivalent code.py. I get:

Traceback (most recent call last):
  File "code.py", line 7, in <module>
  File "adafruit_imageload/__init__.py", line 50, in load
  File "adafruit_imageload/__init__.py", line 49, in load
  File "adafruit_imageload/bmp/__init__.py", line 58, in load
NotImplementedError: True color BMP unsupported

Do you get a safe mode with Beta 7?

@caternuson
Copy link
Contributor

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:
purple.zip

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)
>>> 

@caternuson
Copy link
Contributor

@tannewt I'd say it's working...

bmp_test

Copy link
Contributor

@caternuson caternuson left a 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.

@caternuson caternuson requested a review from a team April 19, 2019 22:51
@caternuson
Copy link
Contributor

Looks like the red and blue channels are getting swapped.
color_test.zip

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

PyPortal running 4.0 beta 7:
color_test

@tannewt
Copy link
Member Author

tannewt commented May 13, 2019

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')

Copy link
Contributor

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 

Copy link
Contributor

@matt-land matt-land left a 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.

@caternuson
Copy link
Contributor

Nice! Same check as above looks better now.
imageload_test2

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 1, 2019
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
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.

5 participants