Skip to content

displayio: added Mapping to bits_per_value getter #8191

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 1 commit into from
Jul 24, 2023
Merged

Conversation

gaweng
Copy link

@gaweng gaweng commented Jul 22, 2023

fixed #4424

Copy link
Collaborator

@FoamyGuy FoamyGuy 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 good to me.

I tested it successfully with this code on a Matrix Portal S3:

import random
import time
import board
import displayio
from adafruit_matrixportal.matrix import Matrix
import bitmaptools

main_group = displayio.Group()

matrix = Matrix()
display = matrix.display

display.show(main_group)

bitmap = displayio.Bitmap(matrix.display.width, matrix.display.height, 257)
print(f"{bitmap.width}, {bitmap.height}")
print(f"bits per value: {bitmap.bits_per_value}")

p = displayio.Palette(3)
p[0] = 0x000000
p[1] = 0x00ff00

bitmaptools.draw_line(bitmap, 0, 0, bitmap.width-1, bitmap.height, 1)
tg = displayio.TileGrid(bitmap=bitmap, pixel_shader=p)
main_group.append(tg)

while True:
    pass

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 03261fe into adafruit:main Jul 24, 2023
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.

Bitmap: Add public function to get the color depth and bits per pixel.
3 participants