Skip to content

PNG file don't show properly. (wrong order in index?) #74

Closed
@riffnshred

Description

@riffnshred

I've found a bug when I upload a PNG file. The image load as the right size but the index of color seems to be all over the place.

I tested both PNG and BMP and the BMP file works great.

# SPDX-FileCopyrightText: 2020 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: MIT

# This example implements a simple two line scroller using
# Adafruit_CircuitPython_Display_Text. Each line has its own color
# and it is possible to modify the example to use other fonts and non-standard
# characters.

import adafruit_display_text.label
import board
import time
import ulab
import displayio
import framebufferio
import rgbmatrix
import terminalio
import adafruit_imageload

displayio.release_displays()

matrix = rgbmatrix.RGBMatrix(
    width=64, height=32, bit_depth=3,
    rgb_pins=[
        board.MTX_R1,
        board.MTX_G1,
        board.MTX_B1,
        board.MTX_R2,
        board.MTX_G2,
        board.MTX_B2
    ],
    addr_pins=[
        board.MTX_ADDRA,
        board.MTX_ADDRB,
        board.MTX_ADDRC,
        board.MTX_ADDRD
    ],
    clock_pin=board.MTX_CLK,
    latch_pin=board.MTX_LAT,
    output_enable_pin=board.MTX_OE,
)

display = framebufferio.FramebufferDisplay(matrix)

# load png image
image, palette = adafruit_imageload.load("ANA.png")

print(f"Logo is {image.width}x{image.height}")

# make tilegrid for the loaded image
tile_grid = displayio.TileGrid(image, pixel_shader=palette)

print(f"TileGrid is {image.width}x{image.height}")

# Put each line of text into a Group, then show that group.
g = displayio.Group()

# add loaded image tilegrid
g.append(tile_grid)
display.show(g)

# You can add more effects in this loop. For instance, maybe you want to set the
# color of each label to a different value.
while True:
    display.refresh(minimum_frames_per_second=0)

PNG version

20231031_085443

BMP version
20231031_085429

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions