Skip to content
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

PNG image offset by 1 line #91

Closed
Neradoc opened this issue Jan 12, 2025 · 1 comment · Fixed by #92
Closed

PNG image offset by 1 line #91

Neradoc opened this issue Jan 12, 2025 · 1 comment · Fixed by #92

Comments

@Neradoc
Copy link
Contributor

Neradoc commented Jan 12, 2025

Using Circuitpyhton 9.2.2 the following code and this PNG image, when showed on a screen (in this case a matrix portal so we can see the pixels), the first line is black, and the other lines are all shifted one line down, and the last line is missing. This does not happen with a BMP (on the right). I haven't had time to do other tests.

Test image: test_pattern

matrix

import displayio
import vectorio
import adafruit_imageload

# import board
# display = board.DISPLAY
from adafruit_matrixportal.matrix import Matrix
matrix = Matrix()
display = matrix.display
display.rotation = 180

display.root_group = displayio.Group()

color_palette = displayio.Palette(1)
color_palette[0] = 0x404000 # dark background for the Matrix Portal
display.root_group.append(vectorio.Rectangle(
    pixel_shader=color_palette,
    width=display.width, height=display.height,
))

image, palette = adafruit_imageload.load(f"test_pattern.png")
display.root_group.append(displayio.TileGrid(image, pixel_shader=palette, x=2, y=2))

while True:
    pass
@FoamyGuy
Copy link
Contributor

This is caused by swapping prev and line buffers prior to writing the data from line into the Bitmap during the PNG loading here: https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad/blob/main/adafruit_imageload/png.py#L171

I've submitted #92 that resolves it by moving the swap to after it writes data to the Bitmap.

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 a pull request may close this issue.

2 participants