Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adafruit/Adafruit_CircuitPython_ImageLoad
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.21.0
Choose a base ref
...
head repository: adafruit/Adafruit_CircuitPython_ImageLoad
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.22.0
Choose a head ref
  • 6 commits
  • 1 file changed
  • 3 contributors

Commits on Jul 26, 2024

  1. Initial Testing

    Initial testing of the transparency block.
    ch4nsuk3 committed Jul 26, 2024
    Copy the full SHA
    3a62483 View commit details

Commits on Jul 31, 2024

  1. Initial Implementation

    Transparency checking works, but there still may be efficient methods.
    ch4nsuk3 committed Jul 31, 2024
    Copy the full SHA
    0aed0e9 View commit details

Commits on Aug 1, 2024

  1. Final Implementation

    Various testing shows using a for loop is the quickest method, beating enumeration and list comprehension.
    ch4nsuk3 committed Aug 1, 2024
    Copy the full SHA
    ce523ff View commit details
  2. Updated author info

    ch4nsuk3 committed Aug 1, 2024
    Copy the full SHA
    a8809b0 View commit details

Commits on Aug 2, 2024

  1. Del trans_data

    Deletes the trans_data list after its no longer needed.
    ch4nsuk3 committed Aug 2, 2024
    Copy the full SHA
    a7ac0db View commit details
  2. Merge pull request #82 from ch4nsuk3/png-transparency

    Png transparency
    FoamyGuy authored Aug 2, 2024
    Copy the full SHA
    7a68dcd View commit details
Showing with 11 additions and 2 deletions.
  1. +11 −2 adafruit_imageload/png.py
13 changes: 11 additions & 2 deletions adafruit_imageload/png.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-FileCopyrightText: 2022 Radomir Dopieralski
# SPDX-FileCopyrightText: 2023 Matt Land
# SPDX-FileCopyrightText: 2024 Channing Ramos
#
# SPDX-License-Identifier: MIT

@@ -10,7 +11,7 @@
Load pixel values (indices or colors) into a bitmap and colors into a palette
from a PNG file.
* Author(s): Radomir Dopieralski, Matt Land
* Author(s): Radomir Dopieralski, Matt Land, Channing Ramos
"""

@@ -48,7 +49,7 @@ def load(
:param object palette: Type to store the palette. Must have API similar to
`displayio.Palette`. Will be skipped if None.
"""
# pylint: disable=too-many-locals,too-many-branches
# pylint: disable=too-many-locals,too-many-branches, consider-using-enumerate, too-many-statements
header = file.read(8)
if header != b"\x89PNG\r\n\x1a\n":
raise ValueError("Not a PNG file")
@@ -86,6 +87,14 @@ def load(
pal = palette(pal_size)
for i in range(pal_size):
pal[i] = file.read(3)
elif chunk == b"tRNS":
if size > len(pal):
raise ValueError("More transparency entries than palette entries")
trns_data = file.read(size)
for i in range(len(trns_data)):
if trns_data[i] == 0:
pal.make_transparent(i)
del trns_data
elif chunk == b"IDAT":
data.extend(file.read(size))
elif chunk == b"IEND":