From e19c2dcd3850ced6f935c773a81827571edbe6f4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 23 Nov 2021 13:14:19 -0600 Subject: [PATCH 001/111] update rtd py version --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 95ec218..1335112 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 python: - version: "3.6" + version: "3.7" install: - requirements: docs/requirements.txt - requirements: requirements.txt From 259a60938d6962995e8b16fd0970effe0da71e7d Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 13 Jan 2022 16:27:30 -0500 Subject: [PATCH 002/111] First part of patch Signed-off-by: dherrada --- .../PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md | 2 +- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 8 ++++---- .readthedocs.yaml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md index 71ef8f8..8de294e 100644 --- a/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +++ b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md @@ -4,7 +4,7 @@ Thank you for contributing! Before you submit a pull request, please read the following. -Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://circuitpython.readthedocs.io/en/latest/docs/design_guide.html +Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca35544..474520d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,10 +22,10 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - name: Set up Python 3.x + uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: "3.x" - name: Versions run: | python3 --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d0015a..a65e5de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,10 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.6 - uses: actions/setup-python@v1 + - name: Set up Python 3.x + uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: "3.x" - name: Versions run: | python3 --version @@ -67,7 +67,7 @@ jobs: echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) - name: Set up Python if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1335112..f8b2891 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 python: - version: "3.7" + version: "3.x" install: - requirements: docs/requirements.txt - requirements: requirements.txt From bb8f23c0fc7e185b3497212114549b558f7a9c3c Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 24 Jan 2022 16:46:16 -0500 Subject: [PATCH 003/111] Updated docs link, updated python docs link, updated setup.py --- README.rst | 4 ++-- docs/conf.py | 4 ++-- docs/index.rst | 2 +- setup.py | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 3ff633e..2386b06 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Introduction ============ .. image:: https://readthedocs.org/projects/adafruit-circuitpython-imageload/badge/?version=latest - :target: https://circuitpython.readthedocs.io/projects/imageload/en/latest/ + :target: https://docs.circuitpython.org/projects/imageload/en/latest/ :alt: Documentation Status .. image:: https://img.shields.io/discord/327254708534116352.svg @@ -45,7 +45,7 @@ Usage Example Documentation ============= -API documentation for this library can be found on `Read the Docs `_. +API documentation for this library can be found on `Read the Docs `_. Contributing ============ diff --git a/docs/conf.py b/docs/conf.py index bf49375..9cf71b5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -29,8 +29,8 @@ intersphinx_mapping = { - "python": ("https://docs.python.org/3.4", None), - "CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), + "python": ("https://docs.python.org/3", None), + "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), } # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index 0023060..c0f0075 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -43,7 +43,7 @@ Table of Contents :caption: Other Links Download - CircuitPython Reference Documentation + CircuitPython Reference Documentation CircuitPython Support Forum Discord Chat Adafruit Learning System diff --git a/setup.py b/setup.py index 73083c5..4dd01bc 100644 --- a/setup.py +++ b/setup.py @@ -46,8 +46,6 @@ "Topic :: System :: Hardware", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", ], # What does your project relate to? keywords="adafruit blinka circuitpython micropython bitmap fonts text display tft lcd displayio imageload image", From 96d3cb1d78ba6e975b080b66dbac000471dfc19c Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Thu, 10 Feb 2022 09:56:52 -0500 Subject: [PATCH 004/111] Consolidate Documentation sections of README --- README.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 2386b06..4d63ca5 100644 --- a/README.rst +++ b/README.rst @@ -47,14 +47,11 @@ Documentation API documentation for this library can be found on `Read the Docs `_. +For information on building library documentation, please check out `this guide `_. + Contributing ============ Contributions are welcome! Please read our `Code of Conduct `_ before contributing to help this project stay welcoming. - -Documentation -============= - -For information on building library documentation, please check out `this guide `_. From 5a505abf1559cb81108453cbb761abdf562ccc7b Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 14 Feb 2022 15:35:02 -0500 Subject: [PATCH 005/111] Fixed readthedocs build Signed-off-by: dherrada --- .readthedocs.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f8b2891..33c2a61 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,8 +8,12 @@ # Required version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3" + python: - version: "3.x" install: - requirements: docs/requirements.txt - requirements: requirements.txt From 7016d920040c909d7419106c627cb201235d6c27 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 28 Mar 2022 15:52:04 -0400 Subject: [PATCH 006/111] Update Black to latest. Signed-off-by: Kattni Rembor --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b9fadc..7467c1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/python/black - rev: 20.8b1 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool From ae94b2a87217d135e82e5bfb5afc3b4af3060aaf Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 29 Mar 2022 18:15:15 -0400 Subject: [PATCH 007/111] "Reformatted per new black version" --- adafruit_imageload/bmp/__init__.py | 2 +- adafruit_imageload/bmp/indexed.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index bab3c54..a8cd86d 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -53,7 +53,7 @@ def load(file, *, bitmap=None, palette=None): raise NotImplementedError("bitmask compression unsupported") if colors == 0: - colors = 2 ** color_depth + colors = 2**color_depth from . import indexed return indexed.load( diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index 1fed132..ba39060 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -58,7 +58,7 @@ def load( if bitmap: minimum_color_depth = 1 - while colors > 2 ** minimum_color_depth: + while colors > 2**minimum_color_depth: minimum_color_depth *= 2 if sys.maxsize > 1073741823: From 4ed4ad360291f39cab9d018cc4e16da422784518 Mon Sep 17 00:00:00 2001 From: Eva Herrada <33632497+evaherrada@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:52:42 -0400 Subject: [PATCH 008/111] Update .gitignore --- .gitignore | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 5865216..544ec4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,47 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries # -# SPDX-License-Identifier: Unlicense +# SPDX-License-Identifier: MIT +# Do not include files and directories created by your personal work environment, such as the IDE +# you use, except for those already listed here. Pull requests including changes to this file will +# not be accepted. + +# This .gitignore file contains rules for files generated by working with CircuitPython libraries, +# including building Sphinx, testing with pip, and creating a virual environment, as well as the +# MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. + +# If you find that there are files being generated on your machine that should not be included in +# your git commit, you should create a .gitignore_global file on your computer to include the +# files created by your personal setup. To do so, follow the two steps below. + +# First, create a file called .gitignore_global somewhere convenient for you, and add rules for +# the files you want to exclude from git commits. + +# Second, configure Git to use the exclude file for all Git repositories by running the +# following via commandline, replacing "path/to/your/" with the actual path to your newly created +# .gitignore_global file: +# git config --global core.excludesfile path/to/your/.gitignore_global + +# CircuitPython-specific files +*.mpy + +# Python-specific files __pycache__ -_build *.pyc + +# Sphinx build-specific files +_build + +# This file results from running `pip -e install .` in a local repository +*.egg-info + +# Virtual environment-specific files .env -bundles -.idea/ -venv/ + +# MacOS-specific files +*.DS_Store + +# IDE-specific files +.idea .vscode -.DS_STORE -develop-eggs/ -eggs/ -.eggs/ -*.egg-info/ -*.egg +*~ From cf5e3c7665c2921b8172391d14f7626996526b7e Mon Sep 17 00:00:00 2001 From: evaherrada Date: Fri, 22 Apr 2022 15:58:47 -0400 Subject: [PATCH 009/111] Patch: Replaced discord badge image --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4d63ca5..ef1a608 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Introduction :target: https://docs.circuitpython.org/projects/imageload/en/latest/ :alt: Documentation Status -.. image:: https://img.shields.io/discord/327254708534116352.svg +.. image:: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/main/badges/adafruit_discord.svg :target: https://adafru.it/discord :alt: Discord From 0d75d6cb5b0928e5e0cf2d7b5087aaa9f5e2fec1 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 22 Apr 2022 16:53:23 -0500 Subject: [PATCH 010/111] adding tilegird_inflator --- adafruit_imageload/tilegrid_inflator.py | 100 ++++++++++++++++++++++++ docs/api.rst | 3 + 2 files changed, 103 insertions(+) create mode 100644 adafruit_imageload/tilegrid_inflator.py diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py new file mode 100644 index 0000000..7f00735 --- /dev/null +++ b/adafruit_imageload/tilegrid_inflator.py @@ -0,0 +1,100 @@ +# SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +""" +`adafruit_imageload.tilegrid_inflator` +==================================================== + +Use a 3x3 spritesheet to inflate a larger grid of tiles, duplicating the center rows and +columns as many times as needed to reach a target size. + +* Author(s): Tim Cocks + +""" + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" + +import displayio +import adafruit_imageload + + +def inflate_tilegrid( + bmp_path=None, + target_size=(3, 3), + tile_size=None, + transparent_index=None, + bmp_obj=None, + bmp_palette=None, +): + """ + inflate a TileGrid of ``target_size`` in tiles from a 3x3 spritesheet by duplicating + the center rows and columns. + + :param string bmp_path: filepath to the 3x3 spritesheet bitmap file + :param tuple target_size: desired size in tiles (target_width, target_height) + :param Optional[tuple] tile_size: size of the tiles in the 3x3 spritesheet. If + None is used it will equally divide the width and height of the Bitmap by 3. + :param Union[tuple, int] transparent_index: a single index within the palette to + make transparent, or a tuple of multiple indexes to make transparent + :param OnDiskBitmap bmp_obj: Already loaded 3x3 spritesheet in an OnDiskBitmap + :param Palette bmp_palette: Already loaded spritesheet Palette + """ + + # pylint: disable=too-many-arguments, too-many-locals, too-many-branches + + if bmp_path is None and (bmp_obj is None and bmp_palette is None): + raise AttributeError("Must pass either bmp_path or bmp_obj and bmp_palette") + + if bmp_path is not None: + image, palette = adafruit_imageload.load(bmp_path) + else: + image = bmp_obj + palette = bmp_palette + + if transparent_index is not None: + if isinstance(transparent_index, tuple): + for index in transparent_index: + palette.make_transparent(index) + elif isinstance(transparent_index, int): + palette.make_transparent(transparent_index) + + if tile_size is None: + tile_width = image.width // 3 + tile_height = image.height // 3 + else: + tile_width = tile_size[0] + tile_height = tile_size[1] + + target_width = target_size[0] + target_height = target_size[1] + + tile_grid = displayio.TileGrid( + image, + pixel_shader=palette, + height=target_height, + width=target_width, + tile_width=tile_width, + tile_height=tile_height, + ) + + # corners + tile_grid[0, 0] = 0 # upper left + tile_grid[tile_grid.width - 1, 0] = 2 # upper right + tile_grid[0, tile_grid.height - 1] = 6 # lower left + tile_grid[tile_grid.width - 1, tile_grid.height - 1] = 8 # lower right + + for x in range(target_size[0] - 2): + tile_grid[x + 1, 0] = 1 + tile_grid[x + 1, tile_grid.height - 1] = 7 + + for y in range(target_size[1] - 2): + tile_grid[0, y + 1] = 3 + tile_grid[tile_grid.width - 1, y + 1] = 5 + + for y in range(target_size[1] - 2): + for x in range(target_size[0] - 2): + tile_grid[x + 1, y + 1] = 4 + + return tile_grid diff --git a/docs/api.rst b/docs/api.rst index 5ef6ad1..0cf10aa 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -12,3 +12,6 @@ .. automodule:: adafruit_imageload.bmp.indexed :members: + +.. automodule:: adafruit_imageload.tilegrid_inflator + :members: From a4672c66897d717a31a10cca9af44fffb91639d9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 23 Apr 2022 14:02:36 -0500 Subject: [PATCH 011/111] adding example for inflator --- .../imageload_tilegrid_inflator_simpletest.py | 17 +++++++++++++++++ examples/images/castle_spritesheet.bmp | Bin 0 -> 1310 bytes examples/images/castle_spritesheet.bmp.license | 2 ++ 3 files changed, 19 insertions(+) create mode 100644 examples/imageload_tilegrid_inflator_simpletest.py create mode 100644 examples/images/castle_spritesheet.bmp create mode 100644 examples/images/castle_spritesheet.bmp.license diff --git a/examples/imageload_tilegrid_inflator_simpletest.py b/examples/imageload_tilegrid_inflator_simpletest.py new file mode 100644 index 0000000..5024b6b --- /dev/null +++ b/examples/imageload_tilegrid_inflator_simpletest.py @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries +# SPDX-License-Identifier: MIT + +import board +import displayio +import adafruit_imageload +from adafruit_imageload.tilegrid_inflator import inflate_tilegrid + +image, palette = adafruit_imageload.load("images/castle_spritesheet.bmp") +tile_grid = inflate_tilegrid(bmp_obj=image, bmp_palette=palette, target_size=(10, 8)) + +group = displayio.Group() +group.append(tile_grid) +board.DISPLAY.show(group) + +while True: + pass diff --git a/examples/images/castle_spritesheet.bmp b/examples/images/castle_spritesheet.bmp new file mode 100644 index 0000000000000000000000000000000000000000..587bef7aeb02a6d67ccee3488ac2acf3e11d0c00 GIT binary patch literal 1310 zcmb7EJ5Izf5FIC>qHz*xl=uW$c`InbZX{@Ekm$Gt1rnm*0$hO}F2Nx<5WF`NCrbzg z-WhxIGJf;MpX{zrk3`!m`X_idx|2fjXAJeRIYTY{OTG0X<&pi|zz#*^5io-o;+a84J;gwQAQ&?w{g`FK6=zP(OP(K%`VZ?0ZB>Of1f9XW z+txb|X9;DgYE%z!{u0hrAh9zX*{zXX*9W-B6kkqtZCjwNt`PZ?9_C%*4RP zriZKMs#^DpGyaMnX*BPOPO7){U+5gyA4*UaDmdhs^-Ma+&wbbRgc>hSr1UzS6uPQ!TH1HiWjGIk41GE$dJ1vR?9lMO7~{{LIQYT9EYO28m}!Z#x`f*~ zCozsAECWED>n+_QJEH;~Tq{qV$Y;ia6t}$KH3K&iXcFqNdyW30A9`GHcuyQ30khcQ Vhff1daeg=QjXn~uiLa{^`3BCNV*mgE literal 0 HcmV?d00001 diff --git a/examples/images/castle_spritesheet.bmp.license b/examples/images/castle_spritesheet.bmp.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/examples/images/castle_spritesheet.bmp.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT From 0815e7863b5fdbd2190ce8b5ec79d0554701ad2c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 23 Apr 2022 14:06:18 -0500 Subject: [PATCH 012/111] add example to docs --- docs/examples.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/examples.rst b/docs/examples.rst index 039d649..6dc236d 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -15,3 +15,12 @@ Loads image that is fetched using adafruit_request .. literalinclude:: ../examples/imageload_from_web.py :caption: examples/imageload_from_web.py :linenos: + +Inflate TileGrid test +--------------------- + +Load 3x3 spritesheet and inflate it to a larger sized TileGrid + +.. literalinclude:: ../examples/imageload_tilegrid_inflator_simpletest.py + :caption: examples/imageload_tilegrid_inflator_simpletest.py + :linenos: From 18ef7765e23b5b86281389e2515b963db9713ead Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sun, 24 Apr 2022 14:04:13 -0500 Subject: [PATCH 013/111] change discord badge --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ef1a608..08d6f1a 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Introduction :target: https://docs.circuitpython.org/projects/imageload/en/latest/ :alt: Documentation Status -.. image:: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/main/badges/adafruit_discord.svg +.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg :target: https://adafru.it/discord :alt: Discord From eaabf2d771c22e718e0dcf59e7a485e7e15c847f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 27 Apr 2022 18:51:25 -0500 Subject: [PATCH 014/111] fix str type and add Optionals for some arguments. --- adafruit_imageload/tilegrid_inflator.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index 7f00735..2cb6aaf 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -32,14 +32,14 @@ def inflate_tilegrid( inflate a TileGrid of ``target_size`` in tiles from a 3x3 spritesheet by duplicating the center rows and columns. - :param string bmp_path: filepath to the 3x3 spritesheet bitmap file - :param tuple target_size: desired size in tiles (target_width, target_height) + :param Optional[str] bmp_path: filepath to the 3x3 spritesheet bitmap file + :param Optional[tuple] target_size: desired size in tiles (target_width, target_height) :param Optional[tuple] tile_size: size of the tiles in the 3x3 spritesheet. If None is used it will equally divide the width and height of the Bitmap by 3. - :param Union[tuple, int] transparent_index: a single index within the palette to + :param Optional[Union[tuple, int]] transparent_index: a single index within the palette to make transparent, or a tuple of multiple indexes to make transparent - :param OnDiskBitmap bmp_obj: Already loaded 3x3 spritesheet in an OnDiskBitmap - :param Palette bmp_palette: Already loaded spritesheet Palette + :param Optional[OnDiskBitmap] bmp_obj: Already loaded 3x3 spritesheet in an OnDiskBitmap + :param Optional[Palette] bmp_palette: Already loaded spritesheet Palette """ # pylint: disable=too-many-arguments, too-many-locals, too-many-branches From bcc61b4ccdc932897f67fe605ca6c8b774e20cb8 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Mon, 2 May 2022 16:26:56 -0600 Subject: [PATCH 015/111] WIP adding types for #56 Missing type annotations finish #56, rename types --- .gitignore | 5 ++ .pre-commit-config.yaml | 1 + .pylintrc | 3 +- adafruit_imageload/__init__.py | 27 +++++++- adafruit_imageload/bmp/__init__.py | 18 +++++- adafruit_imageload/bmp/indexed.py | 51 ++++++++++----- .../bmp/negative_height_check.py | 5 +- adafruit_imageload/displayio_types.py | 26 ++++++++ adafruit_imageload/gif.py | 44 +++++++++---- adafruit_imageload/pnm/__init__.py | 64 +++++++++++++++---- adafruit_imageload/pnm/pbm_ascii.py | 17 ++++- adafruit_imageload/pnm/pbm_binary.py | 20 ++++-- adafruit_imageload/pnm/pgm/__init__.py | 20 +++++- adafruit_imageload/pnm/pgm/ascii.py | 23 +++++-- adafruit_imageload/pnm/pgm/binary.py | 27 ++++++-- adafruit_imageload/pnm/ppm_ascii.py | 34 ++++++++-- adafruit_imageload/pnm/ppm_binary.py | 23 +++++-- adafruit_imageload/tilegrid_inflator.py | 36 +++++++---- docs/developing.rst | 15 +++++ mypy.ini | 8 +++ 20 files changed, 373 insertions(+), 94 deletions(-) create mode 100644 adafruit_imageload/displayio_types.py create mode 100644 mypy.ini diff --git a/.gitignore b/.gitignore index 544ec4a..05787ec 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,8 @@ _build .idea .vscode *~ + +# virtualenv +Pipfile +Pipfile.lock +Makefile diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7467c1d..a4cf3de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,7 @@ repos: types: [python] args: - --disable=consider-using-f-string + - --min-similarity-lines=14 exclude: "^(docs/|examples/|tests/|setup.py$)" - id: pylint name: pylint (example code) diff --git a/.pylintrc b/.pylintrc index b86962e..edfacb5 100644 --- a/.pylintrc +++ b/.pylintrc @@ -252,8 +252,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=4 - +min-similarity-lines=14 [BASIC] diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 23e7151..4724276 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -8,22 +9,42 @@ Load pixel values (indices or colors) into a bitmap and colors into a palette. -* Author(s): Scott Shawcroft +* Author(s): Scott Shawcroft, Matt Land """ # pylint: disable=import-outside-toplevel +try: + from typing import ( + Tuple, + Iterator, + Optional, + List, + Iterable, + Union, + ) + from io import BufferedReader + from displayio import Palette, Bitmap + from .displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file_or_filename, *, bitmap=None, palette=None): +def load( + file_or_filename: Union[str, BufferedReader], + *, + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None +) -> Tuple[Bitmap, Optional[Palette]]: """Load pixel values (indices or colors) into a bitmap and colors into a palette. bitmap is the desired type. It must take width, height and color_depth in the constructor. It must also have a _load_row method to load a row's worth of pixel data. - palette is the desired pallete type. The constructor should take the number of colors and + palette is the desired palette type. The constructor should take the number of colors and support assignment to indices via []. """ if not bitmap or not palette: diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index a8cd86d..86372a8 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -8,16 +9,29 @@ Load pixel values (indices or colors) into a bitmap and colors into a palette from a BMP file. -* Author(s): Scott Shawcroft +* Author(s): Scott Shawcroft, Matt Land """ # pylint: disable=import-outside-toplevel +try: + from typing import Tuple, Optional, Set, List + from io import BufferedReader + from displayio import Palette, Bitmap + from ..displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, *, bitmap=None, palette=None): +def load( + file: BufferedReader, + *, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None +) -> Tuple[Bitmap, Optional[Palette]]: """Loads a bmp image from the open ``file``. Returns tuple of bitmap object and palette object. diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index ba39060..079e19f 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -8,33 +9,43 @@ Load pixel values (indices or colors) into a bitmap and colors into a palette from an indexed BMP. -* Author(s): Scott Shawcroft +* Author(s): Scott Shawcroft, Matt Land """ -__version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" import sys +try: + from typing import Tuple, Optional + from io import BufferedReader + from displayio import Palette, Bitmap + from ..displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + try: from bitmaptools import readinto as _bitmap_readinto except ImportError: - _bitmap_readinto = None # pylint: disable=invalid-name + _bitmap_readinto = None # pylint: disable=invalid-name # type: Callable + + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" def load( - file, - width, - height, - data_start, - colors, - color_depth, - compression, + file: BufferedReader, + width: int, + height: int, + data_start: int, + colors: int, + color_depth: int, + compression: int, *, - bitmap=None, - palette=None -): + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None, +) -> Tuple[Bitmap, Optional[Palette]]: """Loads indexed bitmap data into bitmap and palette objects. :param file file: The open bmp file @@ -46,7 +57,7 @@ def load( :param int compression: 0 - none, 1 - 8bit RLE, 2 - 4bit RLE""" # pylint: disable=too-many-arguments,too-many-locals,too-many-branches if palette: - palette = palette(colors) + palette = palette(colors) # type: Palette file.seek(data_start - colors * 4) for value in range(colors): @@ -67,7 +78,7 @@ def load( # convert unsigned int to signed int when height is negative height = negative_height_check(height) - bitmap = bitmap(width, abs(height), colors) + bitmap = bitmap(width, abs(height), colors) # type: Bitmap file.seek(data_start) line_size = width // (8 // color_depth) if width % (8 // color_depth) != 0: @@ -122,7 +133,13 @@ def load( return bitmap, palette -def decode_rle(bitmap, file, compression, y_range, width): +def decode_rle( + bitmap: Bitmap, + file: BufferedReader, + compression: int, + y_range: Tuple[int, int, int], + width: int, +) -> None: """Helper to decode RLE images""" # pylint: disable=too-many-locals,too-many-nested-blocks,too-many-branches diff --git a/adafruit_imageload/bmp/negative_height_check.py b/adafruit_imageload/bmp/negative_height_check.py index 99317a8..2f61d6f 100644 --- a/adafruit_imageload/bmp/negative_height_check.py +++ b/adafruit_imageload/bmp/negative_height_check.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -6,10 +7,12 @@ Check for negative height on the BMP. Seperated into it's own file to support builds without longint. + +* Author(s): Tim Cocks, Matt Land """ -def negative_height_check(height): +def negative_height_check(height: int) -> int: """Check the height return modified if negative.""" if height > 0x7FFFFFFF: return height - 4294967296 diff --git a/adafruit_imageload/displayio_types.py b/adafruit_imageload/displayio_types.py new file mode 100644 index 0000000..e2ab61b --- /dev/null +++ b/adafruit_imageload/displayio_types.py @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: Matt Land +# +# SPDX-License-Identifier: MIT +""" +`adafruit_imageload.displayio_types` +==================================================== + +This is a utility file for type aliases. +https://mypy.readthedocs.io/en/stable/kinds_of_types.html#type-aliases +Type aliases contain compound declarations (used many places in the project) with a single +definition readable by humans. + +* Author(s): Matt Land + +""" +try: + from typing import Callable + from displayio import Palette, Bitmap + + PaletteConstructor = Callable[[int], Palette] + BitmapConstructor = Callable[[int, int, int], Bitmap] +except ImportError: + pass + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index 8f1dc04..3bf45d0 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2019 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -9,22 +10,35 @@ Load pixel values (indices or colors) into a bitmap and colors into a palette from a GIF file. -* Author(s): Radomir Dopieralski +* Author(s): Radomir Dopieralski, Matt Land """ import struct +try: + from typing import Tuple, Iterator, Optional, List + from io import BufferedReader + from displayio import Palette, Bitmap + from .displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, *, bitmap=None, palette=None): +def load( + file: BufferedReader, + *, + bitmap: BitmapConstructor, + palette: PaletteConstructor = None +) -> Tuple[Bitmap, Optional[Palette]]: """Loads a GIF image from the open ``file``. Returns tuple of bitmap object and palette object. + :param BufferedReader file: The *.gif file being loaded :param object bitmap: Type to store bitmap data. Must have API similar to `displayio.Bitmap`. Will be skipped if None :param object palette: Type to store the palette. Must have API similar to @@ -32,7 +46,9 @@ def load(file, *, bitmap=None, palette=None): header = file.read(6) if header not in {b"GIF87a", b"GIF89a"}: raise ValueError("Not a GIF file") - width, height, flags, _, _ = struct.unpack(" None: + """Read a single frame and apply it to the bitmap.""" + ddx, ddy, width, _, flags = struct.unpack( # pylint: disable=no-member + " Iterator[int]: """Read a block from a file.""" while True: size = file.read(1)[0] @@ -95,21 +113,21 @@ class EndOfData(Exception): class LZWDict: """A dictionary of LZW codes.""" - def __init__(self, code_size): + def __init__(self, code_size: int) -> None: self.code_size = code_size self.clear_code = 1 << code_size self.end_code = self.clear_code + 1 - self.codes = [] - self.last = None + self.codes = [] # type: List[bytes] + self.last = b"" self.clear() - def clear(self): + def clear(self) -> None: """Reset the dictionary to default codes.""" self.last = b"" self.code_len = self.code_size + 1 self.codes[:] = [] - def decode(self, code): + def decode(self, code: int) -> bytes: """Decode a code.""" if code == self.clear_code: self.clear() @@ -133,7 +151,7 @@ def decode(self, code): return value -def lzw_decode(data, code_size): +def lzw_decode(data: Iterator[int], code_size: int) -> Iterator[bytes]: """Decode LZW-compressed data.""" dictionary = LZWDict(code_size) bit = 0 diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index d9631d9..5a79c65 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -16,13 +16,35 @@ """ # pylint: disable=import-outside-toplevel +try: + from typing import ( + Tuple, + Iterator, + Optional, + List, + Iterable, + Union, + Callable, + ) + from io import BufferedReader + from displayio import Palette, Bitmap + from ..displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, header, *, bitmap=None, palette=None): +def load( + file: BufferedReader, + header: bytes, + *, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ - Scan for netpbm format info, skip over comments, and and delegate to a submodule + Scan for netpbm format info, skip over comments, and delegate to a submodule to do the actual data loading. Formats P1, P4 have two space padded pieces of information: width and height. All other formats have three: width, height, and max color value. @@ -31,7 +53,7 @@ def load(file, header, *, bitmap=None, palette=None): # pylint: disable=too-many-branches magic_number = header[:2] file.seek(2) - pnm_header = [] + pnm_header = [] # type: List[int] next_value = bytearray() while True: # We have all we need at length 3 for formats P2, P3, P5, P6 @@ -40,44 +62,64 @@ def load(file, header, *, bitmap=None, palette=None): from . import pgm return pgm.load( - file, magic_number, pnm_header, bitmap=bitmap, palette=palette + file, + magic_number, + pnm_header, + bitmap=bitmap, + palette=palette, ) if magic_number == b"P3": from . import ppm_ascii return ppm_ascii.load( - file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette + file, + pnm_header[0], + pnm_header[1], + bitmap=bitmap, + palette=palette, ) if magic_number == b"P6": from . import ppm_binary return ppm_binary.load( - file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette + file, + pnm_header[0], + pnm_header[1], + bitmap=bitmap, + palette=palette, ) if len(pnm_header) == 2 and magic_number in [b"P1", b"P4"]: - bitmap = bitmap(pnm_header[0], pnm_header[1], 1) + bitmap = bitmap(pnm_header[0], pnm_header[1], 1) # type: Bitmap if palette: - palette = palette(1) + palette = palette(1) # type: Palette palette[0] = b"\xFF\xFF\xFF" if magic_number.startswith(b"P1"): from . import pbm_ascii return pbm_ascii.load( - file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette + file, + pnm_header[0], + pnm_header[1], + bitmap=bitmap, + palette=palette, ) from . import pbm_binary return pbm_binary.load( - file, pnm_header[0], pnm_header[1], bitmap=bitmap, palette=palette + file, + pnm_header[0], + pnm_header[1], + bitmap=bitmap, + palette=palette, ) next_byte = file.read(1) if next_byte == b"": - raise RuntimeError("Unsupported image format {}".format(magic_number)) + raise RuntimeError("Unsupported image format {!r}".format(magic_number)) if next_byte == b"#": # comment found, seek until a newline or EOF is found while file.read(1) not in [b"", b"\n"]: # EOF or NL pass diff --git a/adafruit_imageload/pnm/pbm_ascii.py b/adafruit_imageload/pnm/pbm_ascii.py index c0206f9..d0eac59 100644 --- a/adafruit_imageload/pnm/pbm_ascii.py +++ b/adafruit_imageload/pnm/pbm_ascii.py @@ -16,15 +16,28 @@ """ +try: + from typing import Tuple, Optional + from io import BufferedReader + from displayio import Palette, Bitmap +except ImportError: + pass + __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, width, height, bitmap=None, palette=None): +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: Bitmap, + palette: Palette = None, +) -> Tuple[Bitmap, Optional[Palette]]: """ Load a P1 'PBM' ascii image into the displayio.Bitmap """ - next_byte = True + next_byte = b"1" # just to start the iterator for y in range(height): x = 0 while next_byte: diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index 0bd6ce1..6a801ce 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -15,14 +15,26 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ +try: + from typing import Tuple, Optional, Iterator + from io import BufferedReader + from displayio import Palette, Bitmap +except ImportError: + pass __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, width, height, bitmap=None, palette=None): +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: Bitmap, + palette: Palette = None, +) -> Tuple[Bitmap, Optional[Palette]]: """ - Load a P4 'PBM' binary image into the displayio.Bitmap + Load a P4 'PBM' binary image into the Bitmap """ x = 0 y = 0 @@ -41,7 +53,7 @@ def load(file, width, height, bitmap=None, palette=None): return bitmap, palette -def iterbits(b): +def iterbits(b: bytes) -> Iterator[int]: """ generator to iterate over the bits in a byte (character) """ @@ -50,7 +62,7 @@ def iterbits(b): yield (in_char >> i) & 1 -def reverse(b): +def reverse(b: int) -> int: """ reverse bit order so the iterbits works """ diff --git a/adafruit_imageload/pnm/pgm/__init__.py b/adafruit_imageload/pnm/pgm/__init__.py index e496327..08182b0 100644 --- a/adafruit_imageload/pnm/pgm/__init__.py +++ b/adafruit_imageload/pnm/pgm/__init__.py @@ -15,9 +15,23 @@ """ # pylint: disable=import-outside-toplevel - - -def load(file, magic_number, header, *, bitmap=None, palette=None): +try: + from typing import Tuple, Optional, Set, List + from io import BufferedReader + from displayio import Palette, Bitmap + from ...displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + + +def load( + file: BufferedReader, + magic_number: bytes, + header: List[int], + *, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Perform the load of Netpbm greyscale images (P2, P5) """ diff --git a/adafruit_imageload/pnm/pgm/ascii.py b/adafruit_imageload/pnm/pgm/ascii.py index 777f0c4..4d6db53 100644 --- a/adafruit_imageload/pnm/pgm/ascii.py +++ b/adafruit_imageload/pnm/pgm/ascii.py @@ -14,9 +14,22 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ +try: + from typing import Tuple, Set, Optional + from io import BufferedReader + from displayio import Palette, Bitmap + from ...displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass -def load(file, width, height, bitmap=None, palette=None): +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None, +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Load a PGM ascii file (P2) """ @@ -34,9 +47,9 @@ def load(file, width, height, bitmap=None, palette=None): pixel = bytearray() pixel += byte if palette: - palette = build_palette(palette, _palette_colors) + palette = build_palette(palette, _palette_colors) # type: Palette if bitmap: - bitmap = bitmap(width, height, len(_palette_colors)) + bitmap = bitmap(width, height, len(_palette_colors)) # type: Bitmap _palette_colors = list(_palette_colors) file.seek(data_start) for y in range(height): @@ -52,7 +65,9 @@ def load(file, width, height, bitmap=None, palette=None): return bitmap, palette -def build_palette(palette_class, palette_colors): # pylint: disable=duplicate-code +def build_palette( + palette_class: PaletteConstructor, palette_colors: Set[int] +) -> Palette: # pylint: disable=duplicate-code """ construct the Palette, and populate it with the set of palette_colors """ diff --git a/adafruit_imageload/pnm/pgm/binary.py b/adafruit_imageload/pnm/pgm/binary.py index dcacabd..e1c8cbf 100644 --- a/adafruit_imageload/pnm/pgm/binary.py +++ b/adafruit_imageload/pnm/pgm/binary.py @@ -14,13 +14,26 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ +try: + from typing import Tuple, Optional, Set, List + from io import BufferedReader + from displayio import Palette, Bitmap + from ...displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass -def load(file, width, height, bitmap=None, palette=None): +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None, +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Load a P5 format file (binary), handle PGM (greyscale) """ - palette_colors = set() + palette_colors = set() # type: Set[int] data_start = file.tell() for y in range(height): data_line = iter(bytes(file.read(width))) @@ -28,10 +41,10 @@ def load(file, width, height, bitmap=None, palette=None): palette_colors.add(pixel) if palette: - palette = build_palette(palette, palette_colors) + palette = build_palette(palette, palette_colors) # type: Palette if bitmap: - bitmap = bitmap(width, height, len(palette_colors)) - palette_colors = list(palette_colors) + bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap + palette_colors = list(palette_colors) # type: List[int] file.seek(data_start) for y in range(height): data_line = iter(bytes(file.read(width))) @@ -40,7 +53,9 @@ def load(file, width, height, bitmap=None, palette=None): return bitmap, palette -def build_palette(palette_class, palette_colors): +def build_palette( + palette_class: PaletteConstructor, palette_colors: Set[int] +) -> Palette: """ construct the Palette, and populate it with the set of palette_colors """ diff --git a/adafruit_imageload/pnm/ppm_ascii.py b/adafruit_imageload/pnm/ppm_ascii.py index 2c7929a..678067c 100644 --- a/adafruit_imageload/pnm/ppm_ascii.py +++ b/adafruit_imageload/pnm/ppm_ascii.py @@ -19,8 +19,28 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" +try: + from typing import ( + Tuple, + Iterator, + Optional, + List, + Set, + ) + from io import BufferedReader + from displayio import Palette, Bitmap + from ..displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass -def load(file, width, height, bitmap=None, palette=None): + +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None, +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ :param stream file: infile with the position set at start of data :param int width: @@ -30,19 +50,19 @@ def load(file, width, height, bitmap=None, palette=None): :param palette: displayio.Palette class :return tuple: """ - palette_colors = set() + palette_colors = set() # type: Set[bytes] data_start = file.tell() for triplet in read_three_colors(file): palette_colors.add(triplet) if palette: - palette = palette(len(palette_colors)) + palette = palette(len(palette_colors)) # type: Palette for counter, color in enumerate(palette_colors): palette[counter] = color if bitmap: file.seek(data_start) - bitmap = bitmap(width, height, len(palette_colors)) - palette_colors = list(palette_colors) + bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap + palette_colors = list(palette_colors) # type: List[bytes] for y in range(height): for x in range(width): for color in read_three_colors(file): @@ -51,13 +71,13 @@ def load(file, width, height, bitmap=None, palette=None): return bitmap, palette -def read_three_colors(file): +def read_three_colors(file: BufferedReader) -> Iterator[bytes]: """ Generator to read integer values from file, in groups of three. Each value can be len 1-3, for values 0 - 255, space padded. :return tuple[int]: """ - triplet = [] + triplet = [] # type: List[int] color = bytearray() while True: this_byte = file.read(1) diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index 8ecb5e8..900ddfc 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -15,17 +15,30 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ +try: + from typing import Tuple, Optional, List, Set + from io import BufferedReader + from displayio import Palette, Bitmap + from ..displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file, width, height, bitmap=None, palette=None): +def load( + file: BufferedReader, + width: int, + height: int, + bitmap: BitmapConstructor = None, + palette: PaletteConstructor = None, +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """Load pixel values (indices or colors) into a bitmap and for a binary ppm, return None for pallet.""" data_start = file.tell() - palette_colors = set() + palette_colors = set() # type: Set[Tuple[int, int, int]] line_size = width * 3 for y in range(height): @@ -35,13 +48,13 @@ def load(file, width, height, bitmap=None, palette=None): palette_colors.add((red, next(data_line), next(data_line))) if palette: - palette = palette(len(palette_colors)) + palette = palette(len(palette_colors)) # type: Palette for counter, color in enumerate(palette_colors): palette[counter] = bytes(color) if bitmap: - bitmap = bitmap(width, height, len(palette_colors)) + bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap file.seek(data_start) - palette_colors = list(palette_colors) + palette_colors = list(palette_colors) # type: List[Tuple[int, int, int]] for y in range(height): x = 0 data_line = iter(bytes(file.read(line_size))) diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index 2cb6aaf..5137b42 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries +# SPDX-FileCopyrightText: Matt Land # # SPDX-License-Identifier: MIT @@ -9,25 +10,30 @@ Use a 3x3 spritesheet to inflate a larger grid of tiles, duplicating the center rows and columns as many times as needed to reach a target size. -* Author(s): Tim Cocks +* Author(s): Tim Cocks, Matt Land """ +import displayio +import adafruit_imageload + +try: + from typing import Tuple, Optional, List, Union + from displayio import Palette, Bitmap, OnDiskBitmap, TileGrid +except ImportError: + pass __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -import displayio -import adafruit_imageload - def inflate_tilegrid( - bmp_path=None, - target_size=(3, 3), - tile_size=None, - transparent_index=None, - bmp_obj=None, - bmp_palette=None, -): + bmp_path: str = None, + target_size: Tuple[int, int] = (3, 3), + tile_size: List[int] = None, + transparent_index: Optional[Union[tuple, int]] = None, + bmp_obj: Optional[OnDiskBitmap] = None, + bmp_palette: Optional[Palette] = None, +) -> TileGrid: """ inflate a TileGrid of ``target_size`` in tiles from a 3x3 spritesheet by duplicating the center rows and columns. @@ -47,11 +53,13 @@ def inflate_tilegrid( if bmp_path is None and (bmp_obj is None and bmp_palette is None): raise AttributeError("Must pass either bmp_path or bmp_obj and bmp_palette") + image: Bitmap + palette: Palette if bmp_path is not None: - image, palette = adafruit_imageload.load(bmp_path) + image, palette = adafruit_imageload.load(bmp_path) # type: ignore[assignment] else: - image = bmp_obj - palette = bmp_palette + image = bmp_obj # type: ignore[assignment] + palette = bmp_palette # type: ignore[assignment] if transparent_index is not None: if isinstance(transparent_index, tuple): diff --git a/docs/developing.rst b/docs/developing.rst index 7b1d345..9b6a8fd 100644 --- a/docs/developing.rst +++ b/docs/developing.rst @@ -115,3 +115,18 @@ For example, the Bitmap coordinate ``[0,0]`` has the value (integer) ``5``. This corresponds to the the Palette object's, ``[5]`` which is ``b'\x00\x00\xff\x00'``. This is a byte string that represents a color. + +==================== +Mypy & type checking +==================== + +Mypy was tested with version 0.950 and the mypy.ini in project root. +Since checks are not currently not passing, it is not installed as a commit hook. + +Setup: In your virtual environment, run: + + pip3 install mypy==0.050 + +Developing: To manually run checks, run: + + mypy . diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..5000fb4 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: 2022 Matt Land +# +# SPDX-License-Identifier: Unlicense +[mypy] +python_version = 3.9 +disallow_untyped_defs = True +disable_error_code = no-redef +exclude = (examples|tests|setup.py|docs) From aaf95903fddcf3aacf9e3b806e890bbb6441cd4e Mon Sep 17 00:00:00 2001 From: Matt Land Date: Tue, 3 May 2022 13:41:28 -0600 Subject: [PATCH 016/111] #56 downgrade mypy python version, remove .gitignore changes, add copyright year --- .gitignore | 5 ----- .pre-commit-config.yaml | 1 - adafruit_imageload/__init__.py | 2 +- adafruit_imageload/bmp/__init__.py | 2 +- adafruit_imageload/bmp/indexed.py | 2 +- adafruit_imageload/bmp/negative_height_check.py | 2 +- adafruit_imageload/displayio_types.py | 2 +- adafruit_imageload/gif.py | 2 +- adafruit_imageload/pnm/__init__.py | 2 +- adafruit_imageload/pnm/pbm_ascii.py | 2 +- adafruit_imageload/pnm/pbm_binary.py | 2 +- adafruit_imageload/pnm/pgm/__init__.py | 2 +- adafruit_imageload/pnm/pgm/ascii.py | 2 +- adafruit_imageload/pnm/pgm/binary.py | 2 +- adafruit_imageload/pnm/ppm_ascii.py | 2 +- adafruit_imageload/pnm/ppm_binary.py | 2 +- adafruit_imageload/tilegrid_inflator.py | 2 +- mypy.ini | 2 +- 18 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 05787ec..544ec4a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,8 +45,3 @@ _build .idea .vscode *~ - -# virtualenv -Pipfile -Pipfile.lock -Makefile diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a4cf3de..7467c1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,6 @@ repos: types: [python] args: - --disable=consider-using-f-string - - --min-similarity-lines=14 exclude: "^(docs/|examples/|tests/|setup.py$)" - id: pylint name: pylint (example code) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 4724276..6aec02d 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index 86372a8..255c838 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index 079e19f..632456b 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/adafruit_imageload/bmp/negative_height_check.py b/adafruit_imageload/bmp/negative_height_check.py index 2f61d6f..f16b79e 100644 --- a/adafruit_imageload/bmp/negative_height_check.py +++ b/adafruit_imageload/bmp/negative_height_check.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/adafruit_imageload/displayio_types.py b/adafruit_imageload/displayio_types.py index e2ab61b..6f555c7 100644 --- a/adafruit_imageload/displayio_types.py +++ b/adafruit_imageload/displayio_types.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT """ diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index 3bf45d0..98e3c49 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2019 Radomir Dopieralski for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index 5a79c65..61fb13a 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/pbm_ascii.py b/adafruit_imageload/pnm/pbm_ascii.py index d0eac59..8211dc1 100644 --- a/adafruit_imageload/pnm/pbm_ascii.py +++ b/adafruit_imageload/pnm/pbm_ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index 6a801ce..5e55f00 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/pgm/__init__.py b/adafruit_imageload/pnm/pgm/__init__.py index 08182b0..9cb941d 100644 --- a/adafruit_imageload/pnm/pgm/__init__.py +++ b/adafruit_imageload/pnm/pgm/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/pgm/ascii.py b/adafruit_imageload/pnm/pgm/ascii.py index 4d6db53..300d1eb 100644 --- a/adafruit_imageload/pnm/pgm/ascii.py +++ b/adafruit_imageload/pnm/pgm/ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/pgm/binary.py b/adafruit_imageload/pnm/pgm/binary.py index e1c8cbf..4dd8bff 100644 --- a/adafruit_imageload/pnm/pgm/binary.py +++ b/adafruit_imageload/pnm/pgm/binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/ppm_ascii.py b/adafruit_imageload/pnm/ppm_ascii.py index 678067c..6aab356 100644 --- a/adafruit_imageload/pnm/ppm_ascii.py +++ b/adafruit_imageload/pnm/ppm_ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index 900ddfc..905f140 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index 5137b42..916f0bf 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries -# SPDX-FileCopyrightText: Matt Land +# SPDX-FileCopyrightText: 2022 Matt Land # # SPDX-License-Identifier: MIT diff --git a/mypy.ini b/mypy.ini index 5000fb4..5e6c3a5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Unlicense [mypy] -python_version = 3.9 +python_version = 3.7 disallow_untyped_defs = True disable_error_code = no-redef exclude = (examples|tests|setup.py|docs) From e8074e18e6cd088bf0c139092e463896a600d22b Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 15 May 2022 12:49:19 -0400 Subject: [PATCH 017/111] Patch .pre-commit-config.yaml --- .pre-commit-config.yaml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7467c1d..3343606 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,40 +3,40 @@ # SPDX-License-Identifier: Unlicense repos: -- repo: https://github.com/python/black + - repo: https://github.com/python/black rev: 22.3.0 hooks: - - id: black -- repo: https://github.com/fsfe/reuse-tool - rev: v0.12.1 + - id: black + - repo: https://github.com/fsfe/reuse-tool + rev: v0.14.0 hooks: - - id: reuse -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + - id: reuse + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace -- repo: https://github.com/pycqa/pylint + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/pycqa/pylint rev: v2.11.1 hooks: - - id: pylint + - id: pylint name: pylint (library code) types: [python] args: - --disable=consider-using-f-string exclude: "^(docs/|examples/|tests/|setup.py$)" - - id: pylint + - id: pylint name: pylint (example code) description: Run pylint rules on "examples/*.py" files types: [python] files: "^examples/" args: - - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - - id: pylint + - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code + - id: pylint name: pylint (test code) description: Run pylint rules on "tests/*.py" files types: [python] files: "^tests/" args: - - --disable=missing-docstring,consider-using-f-string,duplicate-code + - --disable=missing-docstring,consider-using-f-string,duplicate-code From 6112d1956ad8321314524b2435b3f960f465de94 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 30 May 2022 14:25:04 -0400 Subject: [PATCH 018/111] Set language to "en" for documentation Signed-off-by: Alec Delaney --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 9cf71b5..9d797af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,7 +60,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 9c13a36fe01b496d102d2f1958873ae777015eeb Mon Sep 17 00:00:00 2001 From: evaherrada Date: Tue, 7 Jun 2022 15:34:28 -0400 Subject: [PATCH 019/111] Added cp.org link to index.rst --- docs/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index c0f0075..9b7d0a4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,7 +42,8 @@ Table of Contents .. toctree:: :caption: Other Links - Download + Download from GitHub + Download Library Bundle CircuitPython Reference Documentation CircuitPython Support Forum Discord Chat From 37a8b9eed853baf6a6eb34a16c2cc7c5889bbccc Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Sat, 18 Jun 2022 09:47:35 -0400 Subject: [PATCH 020/111] Post patch cleanup of .pylintrc --- .pylintrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index edfacb5..1931ace 100644 --- a/.pylintrc +++ b/.pylintrc @@ -9,7 +9,7 @@ # run arbitrary code extension-pkg-whitelist= -# Add files or directories to the blacklist. They should be base names, not +# Add files or directories to the ignore-list. They should be base names, not # paths. ignore=CVS,adafruit_imageload/tests @@ -252,7 +252,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=14 +min-similarity-lines=12 [BASIC] From 69636ff697d9ae4b76c340382cd3f98f4ccec569 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Sat, 18 Jun 2022 10:15:59 -0400 Subject: [PATCH 021/111] Revert min lines of similarity to 14 --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 1931ace..3d854b7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -252,7 +252,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=12 +min-similarity-lines=14 [BASIC] From 9dd531559fc782ba52df996bd6c618edf292150c Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 1 Aug 2022 14:11:03 +0200 Subject: [PATCH 022/111] Add PNG support This is a first stab at adding PNG support. For now there are no filters, so only indexed images will work. --- adafruit_imageload/__init__.py | 4 ++ adafruit_imageload/png.py | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 adafruit_imageload/png.py diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 6aec02d..1eeaed9 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -80,4 +80,8 @@ def load( from . import gif return gif.load(file, bitmap=bitmap, palette=palette) + if header.startswith(b"\x89PN"): + from . import png + + return png.load(file, bitmap=bitmap, palette=palette) raise RuntimeError("Unsupported image format") diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py new file mode 100644 index 0000000..0fdc056 --- /dev/null +++ b/adafruit_imageload/png.py @@ -0,0 +1,90 @@ +# SPDX-FileCopyrightText: 2022 Radomir Dopieralski +# +# SPDX-License-Identifier: MIT + +""" +`adafruit_imageload.png` +==================================================== + +Load pixel values (indices or colors) into a bitmap and colors into a palette +from a PNG file. + +* Author(s): Radomir Dopieralski + +""" + +import struct +import zlib + + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" + + +def load( + file, *, bitmap, palette=None +): # pylint: disable=too-many-locals,too-many-branches + """Loads a PNG image from the open ``file``. + + Returns tuple of bitmap object and palette object. + + :param file: The *.png file being loaded + :param object bitmap: Type to store bitmap data. Must have API similar to + `displayio.Bitmap`. + :param object palette: Type to store the palette. Must have API similar to + `displayio.Palette`. Will be skipped if None""" + header = file.read(8) + if header != b"\x89PNG\r\n\x1a\n": + raise ValueError("Not a PNG file") + del header + data = bytearray() + pal = None + mode = None + depth = None + while True: + size, chunk = struct.unpack(">I4s", file.read(8)) + if chunk == b"IHDR": + ( + width, + height, + depth, + mode, + compression, + filters, + interlaced, + ) = struct.unpack(">IIBBBBB", file.read(13)) + if interlaced: + raise NotImplementedError("Interlaced images unsupported") + # compression and filters must be 0 with current spec + assert compression == 0 + assert filters == 0 + elif chunk == b"PLTE": + if palette is None: + file.seek(size, 1) + else: + if mode != 3: + raise NotImplementedError("Palette in non-indexed image") + pal_size = size // 3 + pal = palette(pal_size) + for i in range(pal_size): + pal[i] = file.read(3) + elif chunk == b"IDAT": + data.extend(file.read(size)) + elif chunk == b"IEND": + break + else: + file.seek(size, 1) # skip unknown chunks + file.seek(4, 1) # skip CRC + data = zlib.decompress(data) + bmp = bitmap(width, height, 1 << depth) + scanline = (width * depth + 7) // 8 + mem = memoryview(bmp) + for y in range(height): + dst = y * scanline + src = y * (scanline + 1) + 1 + filter_ = data[src - 1] + if filter_ == 0: + mem[dst : dst + scanline] = data[src : src + scanline] + else: + raise NotImplementedError("Filters not supported") + return bmp, pal From b9e13bd99e5dc619cde76cabc8c827682e92b475 Mon Sep 17 00:00:00 2001 From: evaherrada Date: Tue, 2 Aug 2022 17:00:41 -0400 Subject: [PATCH 023/111] Added Black formatting badge --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 08d6f1a..e36bf51 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,10 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad/actions/ :alt: Build Status +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Code Style: Black + This library decodes an image file into new bitmap and palette objects of the provided type. It's designed to load code needed during decoding as needed. This is meant to minimize the memory overhead of the decoding code. From 6d4732f27488fed03e0ce1ac5da359751929443b Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 8 Aug 2022 22:05:54 -0400 Subject: [PATCH 024/111] Switched to pyproject.toml --- .github/workflows/build.yml | 18 +++++++----- .github/workflows/release.yml | 17 ++++++----- optional_requirements.txt | 3 ++ pyproject.toml | 51 ++++++++++++++++++++++++++++++++ requirements.txt | 2 +- setup.py | 55 ----------------------------------- 6 files changed, 75 insertions(+), 71 deletions(-) create mode 100644 optional_requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 474520d..22f6582 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,6 +47,8 @@ jobs: pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - name: Library version run: git describe --dirty --always --tags + - name: Setup problem matchers + uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 - name: Pre-commit hooks run: | pre-commit run --all-files @@ -60,16 +62,16 @@ jobs: - name: Build docs working-directory: docs run: sphinx-build -E -W -b html . _build/html - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - name: Build Python package - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | - pip install --upgrade setuptools wheel twine readme_renderer testresources - python setup.py sdist - python setup.py bdist_wheel --universal + pip install --upgrade build twine + for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do + sed -i -e "s/0.0.0-auto.0/1.2.3/" $file; + done; + python -m build twine check dist/* - - name: Setup problem matchers - uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a65e5de..d1b4f8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,25 +61,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - name: Set up Python - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install --upgrade build twine - name: Build and publish - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') env: TWINE_USERNAME: ${{ secrets.pypi_username }} TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | - python setup.py sdist + for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do + sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file; + done; + python -m build twine upload dist/* diff --git a/optional_requirements.txt b/optional_requirements.txt new file mode 100644 index 0000000..d4e27c4 --- /dev/null +++ b/optional_requirements.txt @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..94ac78f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +# SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +[build-system] +requires = [ + "setuptools", + "wheel", +] + +[project] +name = "adafruit-circuitpython-imageload" +description = "Displays text using CircuitPython's displayio." +version = "0.0.0-auto.0" +readme = "README.rst" +authors = [ + {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} +] +urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad"} +keywords = [ + "adafruit", + "blinka", + "circuitpython", + "micropython", + "bitmap", + "fonts", + "text", + "display", + "tft", + "lcd", + "displayio", + "imageload", + "image", +] +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Embedded Systems", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", +] +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools] +packages = ["adafruit_imageload"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} diff --git a/requirements.txt b/requirements.txt index 44cdfd8..274b851 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries # # SPDX-License-Identifier: Unlicense diff --git a/setup.py b/setup.py deleted file mode 100644 index 4dd01bc..0000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -"""A setuptools based setup module. -See: -https://packaging.python.org/en/latest/distributing.html -https://github.com/pypa/sampleproject -""" - -from setuptools import setup, find_packages - -# To use a consistent encoding -from codecs import open -from os import path - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, "README.rst"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="adafruit-circuitpython-imageload", - use_scm_version=True, - setup_requires=["setuptools_scm"], - description="Displays text using CircuitPython's displayio.", - long_description=long_description, - long_description_content_type="text/x-rst", - # The project's main homepage. - url="https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad", - # Author details - author="Adafruit Industries", - author_email="circuitpython@adafruit.com", - install_requires=[ - "Adafruit-Blinka", - "adafruit-blinka-displayio", - ], - # Choose your license - license="MIT", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries", - "Topic :: System :: Hardware", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - ], - # What does your project relate to? - keywords="adafruit blinka circuitpython micropython bitmap fonts text display tft lcd displayio imageload image", - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - packages=["adafruit_imageload", "adafruit_imageload.bmp", "adafruit_imageload.pnm"], -) From 46cc3b48d3b0678e81c72fc8a4ffcd32c5e412f1 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 9 Aug 2022 12:03:54 -0400 Subject: [PATCH 025/111] Add setuptools-scm to build system requirements Signed-off-by: Alec Delaney --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 94ac78f..42fec86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ requires = [ "setuptools", "wheel", + "setuptools-scm", ] [project] From b16e34eda52d132727a51eded17afe2dc509fd95 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 16 Aug 2022 18:09:15 -0400 Subject: [PATCH 026/111] Update version string --- adafruit_imageload/__init__.py | 2 +- adafruit_imageload/bmp/__init__.py | 2 +- adafruit_imageload/bmp/indexed.py | 2 +- adafruit_imageload/displayio_types.py | 2 +- adafruit_imageload/gif.py | 2 +- adafruit_imageload/pnm/__init__.py | 2 +- adafruit_imageload/pnm/pbm_ascii.py | 2 +- adafruit_imageload/pnm/pbm_binary.py | 2 +- adafruit_imageload/pnm/ppm_ascii.py | 2 +- adafruit_imageload/pnm/ppm_binary.py | 2 +- adafruit_imageload/tilegrid_inflator.py | 2 +- pyproject.toml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 6aec02d..1e45354 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -29,7 +29,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index 255c838..ff422e8 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -22,7 +22,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index 632456b..1855a34 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -30,7 +30,7 @@ _bitmap_readinto = None # pylint: disable=invalid-name # type: Callable -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/displayio_types.py b/adafruit_imageload/displayio_types.py index 6f555c7..c46006a 100644 --- a/adafruit_imageload/displayio_types.py +++ b/adafruit_imageload/displayio_types.py @@ -22,5 +22,5 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index 98e3c49..d1ecd8c 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -24,7 +24,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index 61fb13a..36b51c2 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -32,7 +32,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/pnm/pbm_ascii.py b/adafruit_imageload/pnm/pbm_ascii.py index 8211dc1..150f749 100644 --- a/adafruit_imageload/pnm/pbm_ascii.py +++ b/adafruit_imageload/pnm/pbm_ascii.py @@ -23,7 +23,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index 5e55f00..9b6b9ad 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -22,7 +22,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/pnm/ppm_ascii.py b/adafruit_imageload/pnm/ppm_ascii.py index 6aab356..8aa6b39 100644 --- a/adafruit_imageload/pnm/ppm_ascii.py +++ b/adafruit_imageload/pnm/ppm_ascii.py @@ -16,7 +16,7 @@ """ -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" try: diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index 905f140..cf32fb9 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -23,7 +23,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index 916f0bf..0f40f6b 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -22,7 +22,7 @@ except ImportError: pass -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" diff --git a/pyproject.toml b/pyproject.toml index 42fec86..34513c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ requires = [ [project] name = "adafruit-circuitpython-imageload" description = "Displays text using CircuitPython's displayio." -version = "0.0.0-auto.0" +version = "0.0.0+auto.0" readme = "README.rst" authors = [ {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} From 816afcec2396fd944f1c64a42f56cbef6964f2e8 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 16 Aug 2022 21:09:15 -0400 Subject: [PATCH 027/111] Fix version strings in workflow files --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22f6582..cb2f60e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: run: | pip install --upgrade build twine for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0-auto.0/1.2.3/" $file; + sed -i -e "s/0.0.0+auto.0/1.2.3/" $file; done; python -m build twine check dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1b4f8d..f3a0325 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file; + sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file; done; python -m build twine upload dist/* From f909795471e70037c7bf500539924c1aad92dbfd Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 22 Aug 2022 21:36:32 -0400 Subject: [PATCH 028/111] Keep copyright up to date in documentation --- docs/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 9d797af..8519317 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,6 +6,7 @@ import os import sys +import datetime sys.path.insert(0, os.path.abspath("..")) @@ -43,7 +44,8 @@ # General information about the project. project = "Adafruit_ ImageLoad Library" -copyright = "2018 Scott Shawcroft" +current_year = str(datetime.datetime.now().year) +copyright = current_year + " Scott Shawcroft" author = "Scott Shawcroft" # The version info for the project you're documenting, acts as replacement for From 3da18b615762a2c89cbcdde7606d24c3073ccbc6 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 23 Aug 2022 17:26:22 -0400 Subject: [PATCH 029/111] Use year duration range for copyright attribution --- docs/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 8519317..c573b86 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,8 +44,14 @@ # General information about the project. project = "Adafruit_ ImageLoad Library" +creation_year = "2018" current_year = str(datetime.datetime.now().year) -copyright = current_year + " Scott Shawcroft" +year_duration = ( + current_year + if current_year == creation_year + else creation_year + " - " + current_year +) +copyright = year_duration + " Scott Shawcroft" author = "Scott Shawcroft" # The version info for the project you're documenting, acts as replacement for From 59311035700024f4576a60f1f55249683ccf1e78 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 17 Oct 2022 11:58:30 -0500 Subject: [PATCH 030/111] adding type annotations and png example script --- adafruit_imageload/png.py | 10 ++++-- examples/imageload_png_simpletest.py | 43 +++++++++++++++++++++++++ examples/images/test_image.png | Bin 0 -> 5999 bytes examples/images/test_image.png.license | 2 ++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 examples/imageload_png_simpletest.py create mode 100644 examples/images/test_image.png create mode 100644 examples/images/test_image.png.license diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 0fdc056..db304b5 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -13,16 +13,22 @@ """ +try: + # pylint: disable=unused-import + import typing + from .displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + import struct import zlib - __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" def load( - file, *, bitmap, palette=None + file: str, *, bitmap: BitmapConstructor, palette: PaletteConstructor = None ): # pylint: disable=too-many-locals,too-many-branches """Loads a PNG image from the open ``file``. diff --git a/examples/imageload_png_simpletest.py b/examples/imageload_png_simpletest.py new file mode 100644 index 0000000..c1dc09f --- /dev/null +++ b/examples/imageload_png_simpletest.py @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: 2022 Tim Cocks +# SPDX-License-Identifier: MIT + +import board +import displayio +from vectorio import Rectangle +import adafruit_imageload + +# built-in display +display = board.DISPLAY + +# load png image +image, palette = adafruit_imageload.load("images/test_image.png") + +# Set the transparency index color to be hidden +palette.make_transparent(0) + +# make tilegrid for the loaded image +tile_grid = displayio.TileGrid(image, pixel_shader=palette) +tile_grid.x = display.width // 2 - tile_grid.tile_width // 2 +tile_grid.y = display.height // 2 - tile_grid.tile_height // 2 + +# make a blank background +bg_palette = displayio.Palette(1) +bg_palette[0] = 0xFFFFFF +rect = Rectangle( + pixel_shader=bg_palette, width=display.width, height=display.height, x=0, y=0 +) + +# make a group to show on the display +group = displayio.Group() + +# add background +group.append(rect) +# add loaded image tilegrid +group.append(tile_grid) + +# show our group +board.DISPLAY.show(group) + +# loop forever so it stays on the display +while True: + pass diff --git a/examples/images/test_image.png b/examples/images/test_image.png new file mode 100644 index 0000000000000000000000000000000000000000..9e196dc55cffbec374f49a4320a559510000b8a8 GIT binary patch literal 5999 zcmV-#7m(EX>4Tx04R}tkv&MmKpe$iTeVUuMeHErkfDl$1yK=4twIqhgj%6h2a`)bgeDD1 zii@M*T5#}VvFhOBtgC~oAP9bdI665gx=4xtOA0MwJUH&hyL*qjcYwcMW~$jS2B?~4 zq>~9Dn_CfruLz+R5saWqVx~STiYa)GuY36TdKc$e-sk=tJxbnWfKMQvVY*=vuM$1Xmi?dp;vgSSc3&VMBd5P;Z2a&`A79m1_j4C!zhJ`q-8Yw2yw4d*32Tr#;f zz{oL=3RFmrAN&t~cWV|V#@(cF0_c3P?T;ZKxC=CDw*7r<+l><-@C;mOEq|pBOn;JI zYiY3~AhHcyT(>lN54hX``k!>kkQ^yM(_bh6?`QN)IiT+r2(7xkHTQA)0A#4E)D3WO z2n-h~d(GqB-R-^od#2gn4@+lqmpn&6SpWb708mU+MF0Q*1P22G2n-7c4GIYq5(f|l z3=R+q8XE`_AqNx(4;Bg!5*7>~DF+uX2OAjgYg!*}5IIo60drF)PHP=-P9}1b5^XXy zH_QNbRwi~eHZ*}6aLfdJ)&YT6Dt}2aVUZekUn+t)JU%)+I$bM>;sc560F72Kf?zF+ z;RTM?3XWJad1x(`oh6U4AB|%;lgS!_IZ17(C6DD2k!(9^U_FV~7>ef; zjYmsONlQp#KbKNSX)05DWkH&@ER!5wf>}&=+#;3XA(NFkm{3$!QdCjTD3oGKo^VNk zRaskDT36jH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Yidbq zfx~52a9Y%jkK{QUC{!=l?y!NeP{mi>0U;xld^Ad!aXdKC=XyjB2MOctW8ak()cZK4 z?O Date: Thu, 20 Oct 2022 18:20:03 -0400 Subject: [PATCH 031/111] Switch to use unified workflows --- .github/workflows/build.yml | 67 +---------------------- .github/workflows/release.yml | 88 ------------------------------ .github/workflows/release_gh.yml | 18 ++++++ .github/workflows/release_pypi.yml | 19 +++++++ 4 files changed, 39 insertions(+), 153 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_gh.yml create mode 100644 .github/workflows/release_pypi.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb2f60e..82c5085 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,68 +10,5 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Translate Repo Name For Build Tools filename_prefix - id: repo-name - run: | - echo ::set-output name=repo-name::$( - echo ${{ github.repository }} | - awk -F '\/' '{ print tolower($2) }' | - tr '_' '-' - ) - - name: Set up Python 3.x - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Versions - run: | - python3 --version - - name: Checkout Current Repo - uses: actions/checkout@v1 - with: - submodules: true - - name: Checkout tools repo - uses: actions/checkout@v2 - with: - repository: adafruit/actions-ci-circuitpython-libs - path: actions-ci - - name: Install dependencies - # (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.) - run: | - source actions-ci/install.sh - - name: Pip install Sphinx, pre-commit - run: | - pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - - name: Library version - run: git describe --dirty --always --tags - - name: Setup problem matchers - uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 - - name: Pre-commit hooks - run: | - pre-commit run --all-files - - name: Build assets - run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - - name: Archive bundles - uses: actions/upload-artifact@v2 - with: - name: bundles - path: ${{ github.workspace }}/bundles/ - - name: Build docs - working-directory: docs - run: sphinx-build -E -W -b html . _build/html - - name: Check For pyproject.toml - id: need-pypi - run: | - echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - - name: Build Python package - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - run: | - pip install --upgrade build twine - for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0+auto.0/1.2.3/" $file; - done; - python -m build - twine check dist/* + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f3a0325..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,88 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -name: Release Actions - -on: - release: - types: [published] - -jobs: - upload-release-assets: - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Translate Repo Name For Build Tools filename_prefix - id: repo-name - run: | - echo ::set-output name=repo-name::$( - echo ${{ github.repository }} | - awk -F '\/' '{ print tolower($2) }' | - tr '_' '-' - ) - - name: Set up Python 3.x - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Versions - run: | - python3 --version - - name: Checkout Current Repo - uses: actions/checkout@v1 - with: - submodules: true - - name: Checkout tools repo - uses: actions/checkout@v2 - with: - repository: adafruit/actions-ci-circuitpython-libs - path: actions-ci - - name: Install deps - run: | - source actions-ci/install.sh - - name: Build assets - run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - - name: Upload Release Assets - # the 'official' actions version does not yet support dynamically - # supplying asset names to upload. @csexton's version chosen based on - # discussion in the issue below, as its the simplest to implement and - # allows for selecting files with a pattern. - # https://github.com/actions/upload-release-asset/issues/4 - #uses: actions/upload-release-asset@v1.0.1 - uses: csexton/release-asset-action@master - with: - pattern: "bundles/*" - github-token: ${{ secrets.GITHUB_TOKEN }} - - upload-pypi: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Check For pyproject.toml - id: need-pypi - run: | - echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - - name: Set up Python - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - run: | - python -m pip install --upgrade pip - pip install --upgrade build twine - - name: Build and publish - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - env: - TWINE_USERNAME: ${{ secrets.pypi_username }} - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: | - for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file; - done; - python -m build - twine upload dist/* diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml new file mode 100644 index 0000000..94583ca --- /dev/null +++ b/.github/workflows/release_gh.yml @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +name: GitHub Release Actions + +on: + release: + types: [published] + +jobs: + upload-release-assets: + runs-on: ubuntu-latest + steps: + - name: Run GitHub Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-gh@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml new file mode 100644 index 0000000..65775b7 --- /dev/null +++ b/.github/workflows/release_pypi.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +name: PyPI Release Actions + +on: + release: + types: [published] + +jobs: + upload-release-assets: + runs-on: ubuntu-latest + steps: + - name: Run PyPI Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-pypi@main + with: + pypi-username: ${{ secrets.pypi_username }} + pypi-password: ${{ secrets.pypi_password }} From 248dec90a7fef2cafee3f5853bc517f2db255170 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:44:37 -0400 Subject: [PATCH 032/111] Reformatted per pre-commit --- .github/workflows/build.yml | 2 +- .github/workflows/release_gh.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82c5085..041a337 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,4 +11,4 @@ jobs: runs-on: ubuntu-latest steps: - name: Run Build CI workflow - uses: adafruit/workflows-circuitpython-libs/build@main \ No newline at end of file + uses: adafruit/workflows-circuitpython-libs/build@main diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index 94583ca..b8aa8d6 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -15,4 +15,4 @@ jobs: - name: Run GitHub Release CI workflow uses: adafruit/workflows-circuitpython-libs/release-gh@main with: - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} From ebe52e5227f89037bab01b3beac622a60df050ae Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 00:02:50 -0400 Subject: [PATCH 033/111] Switching to composite actions --- .github/workflows/release_gh.yml | 14 +++++--------- .github/workflows/release_pypi.yml | 15 +++++---------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index b8aa8d6..041a337 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -2,17 +2,13 @@ # # SPDX-License-Identifier: MIT -name: GitHub Release Actions +name: Build CI -on: - release: - types: [published] +on: [pull_request, push] jobs: - upload-release-assets: + test: runs-on: ubuntu-latest steps: - - name: Run GitHub Release CI workflow - uses: adafruit/workflows-circuitpython-libs/release-gh@main - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 65775b7..041a337 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -2,18 +2,13 @@ # # SPDX-License-Identifier: MIT -name: PyPI Release Actions +name: Build CI -on: - release: - types: [published] +on: [pull_request, push] jobs: - upload-release-assets: + test: runs-on: ubuntu-latest steps: - - name: Run PyPI Release CI workflow - uses: adafruit/workflows-circuitpython-libs/release-pypi@main - with: - pypi-username: ${{ secrets.pypi_username }} - pypi-password: ${{ secrets.pypi_password }} + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main From 16eacf7b7551429d0a72a07dbc1ffc279c70fc71 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 00:47:00 -0400 Subject: [PATCH 034/111] Updated pylint version to 2.13.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3343606..4c43710 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.11.1 + rev: v2.13.0 hooks: - id: pylint name: pylint (library code) From a760e844f54d061a9839bd5549ce74c4e983ac30 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 08:15:21 -0400 Subject: [PATCH 035/111] Update pylint to 2.15.5 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c43710..0e5fccc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.13.0 + rev: v2.15.5 hooks: - id: pylint name: pylint (library code) From f51426e1514ee4761d70c9252446af752c899174 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 09:12:45 -0400 Subject: [PATCH 036/111] Fix release CI files --- .github/workflows/release_gh.yml | 14 +++++++++----- .github/workflows/release_pypi.yml | 15 ++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index 041a337..b8aa8d6 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -2,13 +2,17 @@ # # SPDX-License-Identifier: MIT -name: Build CI +name: GitHub Release Actions -on: [pull_request, push] +on: + release: + types: [published] jobs: - test: + upload-release-assets: runs-on: ubuntu-latest steps: - - name: Run Build CI workflow - uses: adafruit/workflows-circuitpython-libs/build@main + - name: Run GitHub Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-gh@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 041a337..65775b7 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -2,13 +2,18 @@ # # SPDX-License-Identifier: MIT -name: Build CI +name: PyPI Release Actions -on: [pull_request, push] +on: + release: + types: [published] jobs: - test: + upload-release-assets: runs-on: ubuntu-latest steps: - - name: Run Build CI workflow - uses: adafruit/workflows-circuitpython-libs/build@main + - name: Run PyPI Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-pypi@main + with: + pypi-username: ${{ secrets.pypi_username }} + pypi-password: ${{ secrets.pypi_password }} From 18d0964ca930b09295b2b530e9779355406ef693 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 18:34:33 -0400 Subject: [PATCH 037/111] Update .pylintrc for v2.15.5 --- .pylintrc | 52 ++++++++-------------------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/.pylintrc b/.pylintrc index 3d854b7..40208c3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense @@ -11,9 +11,9 @@ extension-pkg-whitelist= # Add files or directories to the ignore-list. They should be base names, not # paths. -ignore=CVS,adafruit_imageload/tests +ignore=CVS -# Add files or directories matching the regex patterns to the blacklist. The +# Add files or directories matching the regex patterns to the ignore-list. The # regex matches against base names, not paths. ignore-patterns= @@ -26,7 +26,7 @@ jobs=1 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=pylint.extensions.no_self_use # Pickle collected data for later comparisons. persistent=yes @@ -54,8 +54,8 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,unspecified-encoding +# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call +disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -225,12 +225,6 @@ max-line-length=100 # Maximum number of lines in a module max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no @@ -252,42 +246,27 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=14 +min-similarity-lines=12 -[BASIC] -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ +[BASIC] # Regular expression matching correct argument names argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class names -# class-name-hint=[A-Z_][a-zA-Z0-9]+$ -class-name-hint=[A-Z_][a-zA-Z0-9_]+$ - # Regular expression matching correct class names # class-rgx=[A-Z_][a-zA-Z0-9]+$ class-rgx=[A-Z_][a-zA-Z0-9_]+$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ @@ -295,9 +274,6 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # ones are exempt. docstring-min-length=-1 -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ @@ -308,21 +284,12 @@ good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ @@ -338,9 +305,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ From 9b00824381704ca1219ec97f1096dcf3e6aeb1e0 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:16:31 -0400 Subject: [PATCH 038/111] Add .venv to .gitignore Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 544ec4a..db3d538 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ _build # Virtual environment-specific files .env +.venv # MacOS-specific files *.DS_Store From 01152512da79c6eb8f234ca5878f8fdf6669460d Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 19 Jan 2023 23:39:55 -0500 Subject: [PATCH 039/111] Add upload url to release action Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com> --- .github/workflows/release_gh.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index b8aa8d6..9acec60 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -16,3 +16,4 @@ jobs: uses: adafruit/workflows-circuitpython-libs/release-gh@main with: github-token: ${{ secrets.GITHUB_TOKEN }} + upload-url: ${{ github.event.release.upload_url }} From 7ded8d10a945a1b772616b0d3038a569486fdada Mon Sep 17 00:00:00 2001 From: Matt Land Date: Mon, 24 Apr 2023 09:41:53 -0600 Subject: [PATCH 040/111] work for #59 to remove changing types of objects when reassigning rename, remove type overrides more implicit types, and non-matching return types mypy caught errors --- .pre-commit-config.yaml | 14 +++++++++++ adafruit_imageload/__init__.py | 7 +++++- adafruit_imageload/bmp/__init__.py | 8 +++---- adafruit_imageload/bmp/indexed.py | 30 +++++++++++++---------- adafruit_imageload/gif.py | 6 +++-- adafruit_imageload/png.py | 32 ++++++++++++++++--------- adafruit_imageload/pnm/__init__.py | 25 +++++++++++-------- adafruit_imageload/pnm/pbm_ascii.py | 4 ++-- adafruit_imageload/pnm/pbm_binary.py | 4 ++-- adafruit_imageload/pnm/pgm/__init__.py | 6 ++--- adafruit_imageload/pnm/pgm/ascii.py | 17 ++++++------- adafruit_imageload/pnm/pgm/binary.py | 19 ++++++++------- adafruit_imageload/pnm/ppm_ascii.py | 21 ++++++++-------- adafruit_imageload/pnm/ppm_binary.py | 26 +++++++++++--------- adafruit_imageload/tilegrid_inflator.py | 10 ++++---- mypy.ini | 8 ++++++- 16 files changed, 145 insertions(+), 92 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e5fccc..11aa787 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: Unlicense @@ -40,3 +41,16 @@ repos: files: "^tests/" args: - --disable=missing-docstring,consider-using-f-string,duplicate-code + - repo: local + hooks: + - id: mypy + name: mypy (library code) + entry: "mypy ." + language: python + additional_dependencies: ["mypy==1.2.0"] + types: [python] + exclude: "^(docs/|examples/|tests/|setup.py$)" + # use require_serial so that script + # is only called once per commit + require_serial: true + pass_filenames: false diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index a8965d1..bd8cd98 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: MIT @@ -77,10 +77,15 @@ def load( return pnm.load(file, header, bitmap=bitmap, palette=palette) if header.startswith(b"GIF"): + if not bitmap: + raise RuntimeError("bitmap argument required") + from . import gif return gif.load(file, bitmap=bitmap, palette=palette) if header.startswith(b"\x89PN"): + if not bitmap: + raise RuntimeError("bitmap argument required") from . import png return png.load(file, bitmap=bitmap, palette=palette) diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index ff422e8..736188f 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: MIT @@ -29,9 +29,9 @@ def load( file: BufferedReader, *, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None -) -> Tuple[Bitmap, Optional[Palette]]: + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """Loads a bmp image from the open ``file``. Returns tuple of bitmap object and palette object. diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index 1855a34..134b9b3 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: MIT @@ -43,9 +43,9 @@ def load( color_depth: int, compression: int, *, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None, -) -> Tuple[Bitmap, Optional[Palette]]: + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None, +) -> Tuple[Optional[Bitmap], Optional[Palette]]: """Loads indexed bitmap data into bitmap and palette objects. :param file file: The open bmp file @@ -54,19 +54,24 @@ def load( :param int data_start: Byte location where the data starts (after headers) :param int colors: Number of distinct colors in the image :param int color_depth: Number of bits used to store a value - :param int compression: 0 - none, 1 - 8bit RLE, 2 - 4bit RLE""" + :param int compression: 0 - none, 1 - 8bit RLE, 2 - 4bit RLE + :param BitmapConstructor bitmap: a function that returns a displayio.Bitmap + :param PaletteConstructor palette: a function that returns a displayio.Palette + """ # pylint: disable=too-many-arguments,too-many-locals,too-many-branches + palette_obj = None if palette: - palette = palette(colors) # type: Palette + palette_obj = palette(colors) file.seek(data_start - colors * 4) for value in range(colors): c_bytes = file.read(4) # Need to swap red & blue bytes (bytes 0 and 2) - palette[value] = bytes( + palette_obj[value] = bytes( b"".join([c_bytes[2:3], c_bytes[1:2], c_bytes[0:1], c_bytes[3:1]]) ) + bitmap_obj = None if bitmap: minimum_color_depth = 1 while colors > 2**minimum_color_depth: @@ -78,7 +83,7 @@ def load( # convert unsigned int to signed int when height is negative height = negative_height_check(height) - bitmap = bitmap(width, abs(height), colors) # type: Bitmap + bitmap_obj = bitmap(width, abs(height), colors) file.seek(data_start) line_size = width // (8 // color_depth) if width % (8 // color_depth) != 0: @@ -97,10 +102,9 @@ def load( range3 = 1 if compression == 0: - if _bitmap_readinto: _bitmap_readinto( - bitmap, + bitmap_obj, file, bits_per_pixel=color_depth, element_size=4, @@ -120,17 +124,17 @@ def load( pixel = ( chunk[i] >> (8 - color_depth * (x % pixels_per_byte + 1)) ) & mask - bitmap[offset + x] = pixel + bitmap_obj[offset + x] = pixel elif compression in (1, 2): decode_rle( - bitmap=bitmap, + bitmap=bitmap_obj, file=file, compression=compression, y_range=(range1, range2, range3), width=width, ) - return bitmap, palette + return bitmap_obj, palette_obj def decode_rle( diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index d1ecd8c..3cf3a52 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2019 Radomir Dopieralski for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: MIT @@ -32,7 +32,7 @@ def load( file: BufferedReader, *, bitmap: BitmapConstructor, - palette: PaletteConstructor = None + palette: Optional[PaletteConstructor] = None ) -> Tuple[Bitmap, Optional[Palette]]: """Loads a GIF image from the open ``file``. @@ -50,6 +50,8 @@ def load( " Tuple[Bitmap, Optional[Palette]]: + """ + Loads a PNG image from the open ``file``. Returns tuple of bitmap object and palette object. @@ -38,7 +44,9 @@ def load( :param object bitmap: Type to store bitmap data. Must have API similar to `displayio.Bitmap`. :param object palette: Type to store the palette. Must have API similar to - `displayio.Palette`. Will be skipped if None""" + `displayio.Palette`. Will be skipped if None + """ + # pylint: disable=too-many-locals,too-many-branches header = file.read(8) if header != b"\x89PNG\r\n\x1a\n": raise ValueError("Not a PNG file") @@ -46,7 +54,9 @@ def load( data = bytearray() pal = None mode = None - depth = None + depth = 0 + width = 0 + height = 0 while True: size, chunk = struct.unpack(">I4s", file.read(8)) if chunk == b"IHDR": @@ -81,16 +91,16 @@ def load( else: file.seek(size, 1) # skip unknown chunks file.seek(4, 1) # skip CRC - data = zlib.decompress(data) + data_bytes = zlib.decompress(data) bmp = bitmap(width, height, 1 << depth) scanline = (width * depth + 7) // 8 mem = memoryview(bmp) for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - filter_ = data[src - 1] + filter_ = data_bytes[src - 1] if filter_ == 0: - mem[dst : dst + scanline] = data[src : src + scanline] + mem[dst : dst + scanline] = data_bytes[src : src + scanline] else: raise NotImplementedError("Filters not supported") return bmp, pal diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index 36b51c2..66b731d 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -40,8 +40,8 @@ def load( file: BufferedReader, header: bytes, *, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Scan for netpbm format info, skip over comments, and delegate to a submodule @@ -92,10 +92,15 @@ def load( ) if len(pnm_header) == 2 and magic_number in [b"P1", b"P4"]: - bitmap = bitmap(pnm_header[0], pnm_header[1], 1) # type: Bitmap + if not bitmap: + raise RuntimeError( + "A bitmap constructor is required for this type of pnm format file" + ) + bitmap_obj = bitmap(pnm_header[0], pnm_header[1], 1) + palette_obj = None if palette: - palette = palette(1) # type: Palette - palette[0] = b"\xFF\xFF\xFF" + palette_obj = palette(1) + palette_obj[0] = b"\xFF\xFF\xFF" if magic_number.startswith(b"P1"): from . import pbm_ascii @@ -103,8 +108,8 @@ def load( file, pnm_header[0], pnm_header[1], - bitmap=bitmap, - palette=palette, + bitmap=bitmap_obj, + palette=palette_obj, ) from . import pbm_binary @@ -113,8 +118,8 @@ def load( file, pnm_header[0], pnm_header[1], - bitmap=bitmap, - palette=palette, + bitmap=bitmap_obj, + palette=palette_obj, ) next_byte = file.read(1) diff --git a/adafruit_imageload/pnm/pbm_ascii.py b/adafruit_imageload/pnm/pbm_ascii.py index 150f749..0122132 100644 --- a/adafruit_imageload/pnm/pbm_ascii.py +++ b/adafruit_imageload/pnm/pbm_ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -32,7 +32,7 @@ def load( width: int, height: int, bitmap: Bitmap, - palette: Palette = None, + palette: Optional[Palette] = None, ) -> Tuple[Bitmap, Optional[Palette]]: """ Load a P1 'PBM' ascii image into the displayio.Bitmap diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index 9b6b9ad..263cb2c 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -31,7 +31,7 @@ def load( width: int, height: int, bitmap: Bitmap, - palette: Palette = None, + palette: Optional[Palette] = None, ) -> Tuple[Bitmap, Optional[Palette]]: """ Load a P4 'PBM' binary image into the Bitmap diff --git a/adafruit_imageload/pnm/pgm/__init__.py b/adafruit_imageload/pnm/pgm/__init__.py index 9cb941d..3ed43f7 100644 --- a/adafruit_imageload/pnm/pgm/__init__.py +++ b/adafruit_imageload/pnm/pgm/__init__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -29,8 +29,8 @@ def load( magic_number: bytes, header: List[int], *, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Perform the load of Netpbm greyscale images (P2, P5) diff --git a/adafruit_imageload/pnm/pgm/ascii.py b/adafruit_imageload/pnm/pgm/ascii.py index 300d1eb..097665f 100644 --- a/adafruit_imageload/pnm/pgm/ascii.py +++ b/adafruit_imageload/pnm/pgm/ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -27,8 +27,8 @@ def load( file: BufferedReader, width: int, height: int, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None, + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Load a PGM ascii file (P2) @@ -46,11 +46,12 @@ def load( _palette_colors.add(int_pixel) pixel = bytearray() pixel += byte + palette_obj = None if palette: - palette = build_palette(palette, _palette_colors) # type: Palette + palette_obj = build_palette(palette, _palette_colors) + bitmap_obj = None if bitmap: - bitmap = bitmap(width, height, len(_palette_colors)) # type: Bitmap - _palette_colors = list(_palette_colors) + bitmap_obj = bitmap(width, height, len(_palette_colors)) file.seek(data_start) for y in range(height): for x in range(width): @@ -61,8 +62,8 @@ def load( break pixel += byte int_pixel = int("".join(["%c" % char for char in pixel])) - bitmap[x, y] = _palette_colors.index(int_pixel) - return bitmap, palette + bitmap_obj[x, y] = list(_palette_colors).index(int_pixel) + return bitmap_obj, palette_obj def build_palette( diff --git a/adafruit_imageload/pnm/pgm/binary.py b/adafruit_imageload/pnm/pgm/binary.py index 4dd8bff..7e8c56b 100644 --- a/adafruit_imageload/pnm/pgm/binary.py +++ b/adafruit_imageload/pnm/pgm/binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -15,7 +15,7 @@ """ try: - from typing import Tuple, Optional, Set, List + from typing import Tuple, Optional, Set from io import BufferedReader from displayio import Palette, Bitmap from ...displayio_types import PaletteConstructor, BitmapConstructor @@ -27,8 +27,8 @@ def load( file: BufferedReader, width: int, height: int, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None, + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Load a P5 format file (binary), handle PGM (greyscale) @@ -40,17 +40,18 @@ def load( for pixel in data_line: palette_colors.add(pixel) + palette_obj = None if palette: - palette = build_palette(palette, palette_colors) # type: Palette + palette_obj = build_palette(palette, palette_colors) + bitmap_obj = None if bitmap: - bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap - palette_colors = list(palette_colors) # type: List[int] + bitmap_obj = bitmap(width, height, len(palette_colors)) file.seek(data_start) for y in range(height): data_line = iter(bytes(file.read(width))) for x, pixel in enumerate(data_line): - bitmap[x, y] = palette_colors.index(pixel) - return bitmap, palette + bitmap_obj[x, y] = list(palette_colors).index(pixel) + return bitmap_obj, palette_obj def build_palette( diff --git a/adafruit_imageload/pnm/ppm_ascii.py b/adafruit_imageload/pnm/ppm_ascii.py index 8aa6b39..f6bb88b 100644 --- a/adafruit_imageload/pnm/ppm_ascii.py +++ b/adafruit_imageload/pnm/ppm_ascii.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -38,8 +38,8 @@ def load( file: BufferedReader, width: int, height: int, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None, + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ :param stream file: infile with the position set at start of data @@ -55,27 +55,28 @@ def load( for triplet in read_three_colors(file): palette_colors.add(triplet) + palette_obj = None if palette: - palette = palette(len(palette_colors)) # type: Palette + palette_obj = palette(len(palette_colors)) for counter, color in enumerate(palette_colors): - palette[counter] = color + palette_obj[counter] = color + bitmap_obj = None if bitmap: file.seek(data_start) - bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap - palette_colors = list(palette_colors) # type: List[bytes] + bitmap_obj = bitmap(width, height, len(palette_colors)) for y in range(height): for x in range(width): for color in read_three_colors(file): - bitmap[x, y] = palette_colors.index(color) + bitmap_obj[x, y] = list(palette_colors).index(color) break # exit the inner generator - return bitmap, palette + return bitmap_obj, palette_obj def read_three_colors(file: BufferedReader) -> Iterator[bytes]: """ Generator to read integer values from file, in groups of three. Each value can be len 1-3, for values 0 - 255, space padded. - :return tuple[int]: + :return Iterator[bytes]: """ triplet = [] # type: List[int] color = bytearray() diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index cf32fb9..c828654 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # SPDX-FileCopyrightText: Brooke Storm # SPDX-FileCopyrightText: Sam McGahan # @@ -31,11 +31,14 @@ def load( file: BufferedReader, width: int, height: int, - bitmap: BitmapConstructor = None, - palette: PaletteConstructor = None, + bitmap: Optional[BitmapConstructor] = None, + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: - """Load pixel values (indices or colors) into a bitmap and for a binary - ppm, return None for pallet.""" + """ + Load pixel values (indices or colors) into a bitmap and for a binary + ppm, return None for pallet. + """ + # pylint: disable=too-many-locals data_start = file.tell() palette_colors = set() # type: Set[Tuple[int, int, int]] @@ -47,22 +50,23 @@ def load( # red, green, blue palette_colors.add((red, next(data_line), next(data_line))) + palette_obj = None if palette: - palette = palette(len(palette_colors)) # type: Palette + palette_obj = palette(len(palette_colors)) for counter, color in enumerate(palette_colors): - palette[counter] = bytes(color) + palette_obj[counter] = bytes(color) + bitmap_obj = None if bitmap: - bitmap = bitmap(width, height, len(palette_colors)) # type: Bitmap + bitmap_obj = bitmap(width, height, len(palette_colors)) file.seek(data_start) - palette_colors = list(palette_colors) # type: List[Tuple[int, int, int]] for y in range(height): x = 0 data_line = iter(bytes(file.read(line_size))) for red in data_line: # red, green, blue - bitmap[x, y] = palette_colors.index( + bitmap_obj[x, y] = list(palette_colors).index( (red, next(data_line), next(data_line)) ) x += 1 - return bitmap, palette + return bitmap_obj, palette_obj diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index 0f40f6b..db6c65f 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: MIT @@ -27,9 +27,9 @@ def inflate_tilegrid( - bmp_path: str = None, + bmp_path: Optional[str] = None, target_size: Tuple[int, int] = (3, 3), - tile_size: List[int] = None, + tile_size: Optional[List[int]] = None, transparent_index: Optional[Union[tuple, int]] = None, bmp_obj: Optional[OnDiskBitmap] = None, bmp_palette: Optional[Palette] = None, @@ -39,8 +39,8 @@ def inflate_tilegrid( the center rows and columns. :param Optional[str] bmp_path: filepath to the 3x3 spritesheet bitmap file - :param Optional[tuple] target_size: desired size in tiles (target_width, target_height) - :param Optional[tuple] tile_size: size of the tiles in the 3x3 spritesheet. If + :param tuple[int, int] target_size: desired size in tiles (target_width, target_height) + :param Optional[List[int]] tile_size: size of the tiles in the 3x3 spritesheet. If None is used it will equally divide the width and height of the Bitmap by 3. :param Optional[Union[tuple, int]] transparent_index: a single index within the palette to make transparent, or a tuple of multiple indexes to make transparent diff --git a/mypy.ini b/mypy.ini index 5e6c3a5..a24b0e4 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Matt Land # # SPDX-License-Identifier: Unlicense [mypy] @@ -6,3 +6,9 @@ python_version = 3.7 disallow_untyped_defs = True disable_error_code = no-redef exclude = (examples|tests|setup.py|docs) + +[mypy-displayio] +ignore_missing_imports = True + +[mypy-bitmaptools] +ignore_missing_imports = True From ae65dc37e828eaeef915bf981f043dc8e30b643c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 25 Apr 2023 18:13:21 -0500 Subject: [PATCH 041/111] revert pre-commit mypy task change for now. --- .pre-commit-config.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11aa787..0e5fccc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,4 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò -# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: Unlicense @@ -41,16 +40,3 @@ repos: files: "^tests/" args: - --disable=missing-docstring,consider-using-f-string,duplicate-code - - repo: local - hooks: - - id: mypy - name: mypy (library code) - entry: "mypy ." - language: python - additional_dependencies: ["mypy==1.2.0"] - types: [python] - exclude: "^(docs/|examples/|tests/|setup.py$)" - # use require_serial so that script - # is only called once per commit - require_serial: true - pass_filenames: false From d2c3d321d561fd5922f23bc5953766e2d78ff742 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 5 May 2023 15:55:30 +0200 Subject: [PATCH 042/111] Add png and gif to docs, and note PNG format restriction --- adafruit_imageload/bmp/__init__.py | 2 ++ adafruit_imageload/gif.py | 7 ++++--- adafruit_imageload/png.py | 6 ++++-- docs/api.rst | 6 ++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index 736188f..03532d0 100644 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -36,6 +36,8 @@ def load( Returns tuple of bitmap object and palette object. + :param io.BufferedReader file: Open file handle or compatible (like `io.BytesIO`) + with the data of a BMP file. :param object bitmap: Type to store bitmap data. Must have API similar to `displayio.Bitmap`. Will be skipped if None :param object palette: Type to store the palette. Must have API similar to diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index 3cf3a52..f1a05e4 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -38,11 +38,12 @@ def load( Returns tuple of bitmap object and palette object. - :param BufferedReader file: The *.gif file being loaded + :param io.BufferedReader file: Open file handle or compatible (like `io.BytesIO`) + with the data of a GIF file. :param object bitmap: Type to store bitmap data. Must have API similar to `displayio.Bitmap`. - Will be skipped if None :param object palette: Type to store the palette. Must have API similar to - `displayio.Palette`. Will be skipped if None""" + `displayio.Palette`. Will be skipped if None. + """ header = file.read(6) if header not in {b"GIF87a", b"GIF89a"}: raise ValueError("Not a GIF file") diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 4c3ae71..34b32f0 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -37,14 +37,16 @@ def load( ) -> Tuple[Bitmap, Optional[Palette]]: """ Loads a PNG image from the open ``file``. + Only supports indexed color images. Returns tuple of bitmap object and palette object. - :param file: The *.png file being loaded + :param io.BufferedReader file: Open file handle or compatible (like `io.BytesIO`) + with the data of a PNG file. :param object bitmap: Type to store bitmap data. Must have API similar to `displayio.Bitmap`. :param object palette: Type to store the palette. Must have API similar to - `displayio.Palette`. Will be skipped if None + `displayio.Palette`. Will be skipped if None. """ # pylint: disable=too-many-locals,too-many-branches header = file.read(8) diff --git a/docs/api.rst b/docs/api.rst index 0cf10aa..14b5c05 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -13,5 +13,11 @@ .. automodule:: adafruit_imageload.bmp.indexed :members: +.. automodule:: adafruit_imageload.gif + :members: + +.. automodule:: adafruit_imageload.png + :members: + .. automodule:: adafruit_imageload.tilegrid_inflator :members: From 328541d136736be2e1124d75920c6974a546d1f5 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Tue, 9 May 2023 20:26:25 -0400 Subject: [PATCH 043/111] Update pre-commit hooks Signed-off-by: Tekktrik --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e5fccc..70ade69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,21 +4,21 @@ repos: - repo: https://github.com/python/black - rev: 22.3.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool - rev: v0.14.0 + rev: v1.1.2 hooks: - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.15.5 + rev: v2.17.4 hooks: - id: pylint name: pylint (library code) From 3e75725e9e7b60897540e65a7c65f56cfa4978c2 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Thu, 11 May 2023 00:34:23 -0400 Subject: [PATCH 044/111] Linted per pre-commit --- adafruit_imageload/pnm/ppm_binary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index c828654..b726dc4 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -16,7 +16,7 @@ """ try: - from typing import Tuple, Optional, List, Set + from typing import Tuple, Optional, Set from io import BufferedReader from displayio import Palette, Bitmap from ..displayio_types import PaletteConstructor, BitmapConstructor From ad55332bee1ef8994fab610898975a4122008356 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Thu, 11 May 2023 00:36:05 -0400 Subject: [PATCH 045/111] Specify Exception as builtins --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 40208c3..f945e92 100644 --- a/.pylintrc +++ b/.pylintrc @@ -396,4 +396,4 @@ min-public-methods=1 # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception From 04270548d0e9558c6782633847faaeddb391b6c5 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Tue, 23 May 2023 22:50:01 -0400 Subject: [PATCH 046/111] Fix jQuery for docs --- docs/conf.py | 1 + docs/requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index c573b86..93b8799 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,6 +17,7 @@ # ones. extensions = [ "sphinx.ext.autodoc", + "sphinxcontrib.jquery", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx.ext.todo", diff --git a/docs/requirements.txt b/docs/requirements.txt index 88e6733..797aa04 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,3 +3,4 @@ # SPDX-License-Identifier: Unlicense sphinx>=4.0.0 +sphinxcontrib-jquery From 9f2cec9a38c4e79dc8b8777801914255166805d7 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 3 Aug 2023 15:51:56 -0700 Subject: [PATCH 047/111] Add 16, 24, and 32-bit bmp support --- adafruit_imageload/bmp/__init__.py | 14 ++++- adafruit_imageload/bmp/truecolor.py | 90 +++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) mode change 100644 => 100755 adafruit_imageload/bmp/__init__.py create mode 100755 adafruit_imageload/bmp/truecolor.py diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py old mode 100644 new mode 100755 index 03532d0..b4409fb --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -62,12 +62,20 @@ def load( file.seek(0x2E) # Number of colors in the color palette colors = int.from_bytes(file.read(4), "little") - if colors == 0 and color_depth >= 16: - raise NotImplementedError("True color BMP unsupported") - if compression > 2: raise NotImplementedError("bitmask compression unsupported") + if colors == 0 and color_depth >= 16: + from . import truecolor + + return truecolor.load( + file, + _width, + _height, + data_start, + color_depth, + bitmap=bitmap, + ) if colors == 0: colors = 2**color_depth from . import indexed diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py new file mode 100755 index 0000000..5317ba0 --- /dev/null +++ b/adafruit_imageload/bmp/truecolor.py @@ -0,0 +1,90 @@ +# SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries +# SPDX-FileCopyrightText: 2022-2023 Matt Land +# +# SPDX-License-Identifier: MIT + +""" +`adafruit_imageload.bmp.indexed` +==================================================== + +Load pixel values (indices or colors) into a bitmap and colors into a palette from an indexed BMP. + +* Author(s): Scott Shawcroft, Matt Land, Melissa LeBlanc-Williams + +""" + +import sys + +try: + from typing import Tuple, Optional + from io import BufferedReader + from displayio import Bitmap + from ..displayio_types import BitmapConstructor +except ImportError: + pass + +from displayio import ColorConverter, Colorspace + +__version__ = "0.0.0+auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" + + +def load( + file: BufferedReader, + width: int, + height: int, + data_start: int, + color_depth: int, + *, + bitmap: Optional[BitmapConstructor] = None, +) -> Tuple[Optional[Bitmap], Optional[ColorConverter]]: + """Loads truecolor bitmap data into bitmap and palette objects. Due to the 16-bit limit + that the bitmap object can hold, colors will be converted to 16-bit RGB565 values. + + :param file file: The open bmp file + :param int width: Image width in pixels + :param int height: Image height in pixels + :param int data_start: Byte location where the data starts (after headers) + :param int color_depth: Number of bits used to store a value + :param BitmapConstructor bitmap: a function that returns a displayio.Bitmap + """ + # pylint: disable=too-many-arguments,too-many-locals,too-many-branches + converter_obj = None + bitmap_obj = None + if bitmap: + input_colorspace = Colorspace.RGB888 + if color_depth == 16: + input_colorspace = Colorspace.RGB555 + converter_obj = ColorConverter(input_colorspace=input_colorspace) + if sys.maxsize > 1073741823: + # pylint: disable=import-outside-toplevel, relative-beyond-top-level + from .negative_height_check import negative_height_check + + # convert unsigned int to signed int when height is negative + height = negative_height_check(height) + bitmap_obj = bitmap(width, abs(height), 65535) + file.seek(data_start) + line_size = width * (color_depth // 8) + if height > 0: + range1 = height - 1 + range2 = -1 + range3 = -1 + else: + range1 = 0 + range2 = abs(height) + range3 = 1 + chunk = bytearray(line_size) + for y in range(range1, range2, range3): + file.readinto(chunk) + bytes_per_pixel = color_depth // 8 + offset = y * width + + for x in range(width): + i = x * bytes_per_pixel + if color_depth == 16: + pixel = chunk[i] | chunk[i + 1] << 8 + else: + pixel = chunk[i + 2] << 16 | chunk[i + 1] << 8 | chunk[i] + bitmap_obj[offset + x] = converter_obj.convert(pixel) + + return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565) From c4a4c5ae5be441864265df84440e3f61b251aecf Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 3 Aug 2023 15:54:24 -0700 Subject: [PATCH 048/111] Fix up headers --- adafruit_imageload/bmp/truecolor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py index 5317ba0..c81ed26 100755 --- a/adafruit_imageload/bmp/truecolor.py +++ b/adafruit_imageload/bmp/truecolor.py @@ -1,15 +1,15 @@ # SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries -# SPDX-FileCopyrightText: 2022-2023 Matt Land +# SPDX-FileCopyrightText: 2022-2023 Melissa LeBlanc-Williams # # SPDX-License-Identifier: MIT """ -`adafruit_imageload.bmp.indexed` +`adafruit_imageload.bmp.truecolor` ==================================================== -Load pixel values (indices or colors) into a bitmap and colors into a palette from an indexed BMP. +Load pixel colors into a bitmap from an truecolor BMP and return the correct colorconverter. -* Author(s): Scott Shawcroft, Matt Land, Melissa LeBlanc-Williams +* Author(s): Melissa LeBlanc-Williams """ From f6ddfcee2876cfb8bf9149f17585c14783a70daf Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 3 Aug 2023 16:19:25 -0700 Subject: [PATCH 049/111] Add some comments --- adafruit_imageload/bmp/truecolor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py index c81ed26..710d6bf 100755 --- a/adafruit_imageload/bmp/truecolor.py +++ b/adafruit_imageload/bmp/truecolor.py @@ -52,6 +52,8 @@ def load( converter_obj = None bitmap_obj = None if bitmap: + # Set up a ColorConverter object and set appropriate colorspace + # to convert from based on the color depth input_colorspace = Colorspace.RGB888 if color_depth == 16: input_colorspace = Colorspace.RGB555 @@ -65,6 +67,7 @@ def load( bitmap_obj = bitmap(width, abs(height), 65535) file.seek(data_start) line_size = width * (color_depth // 8) + # Set the seek direction based on whether the height value is negative or positive if height > 0: range1 = height - 1 range2 = -1 From 8e3b8ceea6ca8e35c2808dd2dee971d3f2e94cb1 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 9 Aug 2023 11:16:30 -0700 Subject: [PATCH 050/111] Add Bitfield Compression Support --- adafruit_imageload/bmp/__init__.py | 17 ++++++-- adafruit_imageload/bmp/truecolor.py | 60 +++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index b4409fb..56d9b7c 100755 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -44,8 +44,8 @@ def load( `displayio.Palette`. Will be skipped if None""" file.seek(10) data_start = int.from_bytes(file.read(4), "little") - # f.seek(14) - # bmp_header_length = int.from_bytes(file.read(4), 'little') + file.seek(14) + bmp_header_length = int.from_bytes(file.read(4), "little") # print(bmp_header_length) file.seek(0x12) # Width of the bitmap in pixels _width = int.from_bytes(file.read(4), "little") @@ -61,8 +61,18 @@ def load( compression = int.from_bytes(file.read(2), "little") file.seek(0x2E) # Number of colors in the color palette colors = int.from_bytes(file.read(4), "little") + bitfield_masks = None + if compression == 3 and bmp_header_length >= 56: + bitfield_masks = {} + endianess = "little" if color_depth == 16 else "big" + file.seek(0x36) + bitfield_masks["red"] = int.from_bytes(file.read(4), endianess) + file.seek(0x3A) + bitfield_masks["green"] = int.from_bytes(file.read(4), endianess) + file.seek(0x3E) + bitfield_masks["blue"] = int.from_bytes(file.read(4), endianess) - if compression > 2: + if compression > 3: raise NotImplementedError("bitmask compression unsupported") if colors == 0 and color_depth >= 16: @@ -74,6 +84,7 @@ def load( _height, data_start, color_depth, + bitfield_masks, bitmap=bitmap, ) if colors == 0: diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py index 710d6bf..b1b0889 100755 --- a/adafruit_imageload/bmp/truecolor.py +++ b/adafruit_imageload/bmp/truecolor.py @@ -16,18 +16,41 @@ import sys try: - from typing import Tuple, Optional + from typing import Union, Optional, Tuple from io import BufferedReader - from displayio import Bitmap from ..displayio_types import BitmapConstructor except ImportError: pass -from displayio import ColorConverter, Colorspace +from displayio import ColorConverter, Colorspace, Bitmap __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" +bitfield_colorspaces = ( + { # 16-bit RGB555 + "mask_values": (0x00007C00, 0x000003E0, 0x0000001F), + "color_space": Colorspace.RGB555, + }, + { # 16-bit RGB565 + "mask_values": (0x0000F800, 0x000007E0, 0x0000001F), + "color_space": Colorspace.RGB565, + }, + { # 24 or 32-bit RGB888 (Alpha ignored for 32-bit) + "mask_values": (0x0000FF00, 0x00FF0000, 0xFF000000), + "color_space": Colorspace.RGB888, + }, +) + + +def bitfield_format(bitfield_mask): + """Returns the colorspace for the given bitfield mask""" + mask = (bitfield_mask["red"], bitfield_mask["green"], bitfield_mask["blue"]) + for colorspace in bitfield_colorspaces: + if colorspace["mask_values"] == mask: + return colorspace["color_space"] + return None + def load( file: BufferedReader, @@ -35,6 +58,7 @@ def load( height: int, data_start: int, color_depth: int, + bitfield_masks: Union[dict, None], *, bitmap: Optional[BitmapConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[ColorConverter]]: @@ -46,6 +70,7 @@ def load( :param int height: Image height in pixels :param int data_start: Byte location where the data starts (after headers) :param int color_depth: Number of bits used to store a value + :param dict bitfield_masks: The bitfield masks for each color if using bitfield compression :param BitmapConstructor bitmap: a function that returns a displayio.Bitmap """ # pylint: disable=too-many-arguments,too-many-locals,too-many-branches @@ -55,7 +80,13 @@ def load( # Set up a ColorConverter object and set appropriate colorspace # to convert from based on the color depth input_colorspace = Colorspace.RGB888 - if color_depth == 16: + if bitfield_masks is not None: + colorspace = bitfield_format(bitfield_masks) + if colorspace is not None: + input_colorspace = colorspace + else: + raise NotImplementedError("Bitfield mask not supported") + elif color_depth == 16: input_colorspace = Colorspace.RGB555 converter_obj = ColorConverter(input_colorspace=input_colorspace) if sys.maxsize > 1073741823: @@ -64,7 +95,7 @@ def load( # convert unsigned int to signed int when height is negative height = negative_height_check(height) - bitmap_obj = bitmap(width, abs(height), 65535) + bitmap_obj = Bitmap(width, abs(height), 65535) file.seek(data_start) line_size = width * (color_depth // 8) # Set the seek direction based on whether the height value is negative or positive @@ -84,10 +115,23 @@ def load( for x in range(width): i = x * bytes_per_pixel - if color_depth == 16: - pixel = chunk[i] | chunk[i + 1] << 8 + if bitfield_masks is not None: + color = 0 + for byte in range(bytes_per_pixel): + color |= chunk[i + byte] << (8 * byte) + mask = ( + bitfield_masks["red"] + | bitfield_masks["green"] + | bitfield_masks["blue"] + ) + if color_depth in (24, 32): + mask = mask >> 8 + pixel = color & mask else: - pixel = chunk[i + 2] << 16 | chunk[i + 1] << 8 | chunk[i] + if color_depth == 16: + pixel = chunk[i] | chunk[i + 1] << 8 + else: + pixel = chunk[i + 2] << 16 | chunk[i + 1] << 8 | chunk[i] bitmap_obj[offset + x] = converter_obj.convert(pixel) return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565) From b32499ce3f1c6e0dcec1794b317dd33fbfabb970 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 19 Sep 2023 18:49:43 -0500 Subject: [PATCH 051/111] fix rtd theme --- docs/conf.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 93b8799..86f66b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -101,19 +101,10 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: # only import and set the theme if we're building docs locally - try: - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] - except: - html_theme = "default" - html_theme_path = ["."] -else: - html_theme_path = ["."] +import sphinx_rtd_theme + +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From 85615cf89701a470db1380e236d88bcffe88334d Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 2 Nov 2023 23:46:51 -0400 Subject: [PATCH 052/111] Replace depreciated .show() --- examples/imageload_colorwheel.py | 2 +- examples/imageload_from_web.py | 2 +- examples/imageload_magtag_simpletest.py | 2 +- examples/imageload_netpbm.py | 2 +- examples/imageload_png_simpletest.py | 2 +- examples/imageload_simpletest.py | 2 +- examples/imageload_tilegrid_inflator_simpletest.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/imageload_colorwheel.py b/examples/imageload_colorwheel.py index 5946db9..d43d378 100644 --- a/examples/imageload_colorwheel.py +++ b/examples/imageload_colorwheel.py @@ -15,6 +15,6 @@ group = displayio.Group() group.append(tile_grid) -display.show(group) +display.root_group = group while True: pass diff --git a/examples/imageload_from_web.py b/examples/imageload_from_web.py index 9168cd3..283eb59 100644 --- a/examples/imageload_from_web.py +++ b/examples/imageload_from_web.py @@ -41,7 +41,7 @@ group = displayio.Group(scale=1) group.append(tile_grid) -board.DISPLAY.show(group) +board.DISPLAY.root_group = group response.close() diff --git a/examples/imageload_magtag_simpletest.py b/examples/imageload_magtag_simpletest.py index 04651cf..ad95515 100644 --- a/examples/imageload_magtag_simpletest.py +++ b/examples/imageload_magtag_simpletest.py @@ -27,7 +27,7 @@ group.append(tile_grid) # show the group and refresh -display.show(group) +display.root_group = group display.refresh() while True: diff --git a/examples/imageload_netpbm.py b/examples/imageload_netpbm.py index c6347b4..b896e6e 100644 --- a/examples/imageload_netpbm.py +++ b/examples/imageload_netpbm.py @@ -28,7 +28,7 @@ # Make the display context splash = displayio.Group() -display.show(splash) +display.root_group = splash # image = "images/netpbm_p1_mono_ascii.pbm" # image = "images/netpbm_p2_ascii.pgm" # image = "images/netpbm_p3_rgb_ascii.ppm" diff --git a/examples/imageload_png_simpletest.py b/examples/imageload_png_simpletest.py index c1dc09f..07484e7 100644 --- a/examples/imageload_png_simpletest.py +++ b/examples/imageload_png_simpletest.py @@ -36,7 +36,7 @@ group.append(tile_grid) # show our group -board.DISPLAY.show(group) +board.DISPLAY.root_group = group # loop forever so it stays on the display while True: diff --git a/examples/imageload_simpletest.py b/examples/imageload_simpletest.py index 692f013..fbfc52d 100644 --- a/examples/imageload_simpletest.py +++ b/examples/imageload_simpletest.py @@ -11,7 +11,7 @@ group = displayio.Group() group.append(tile_grid) -board.DISPLAY.show(group) +board.DISPLAY.root_group = group while True: pass diff --git a/examples/imageload_tilegrid_inflator_simpletest.py b/examples/imageload_tilegrid_inflator_simpletest.py index 5024b6b..50463a0 100644 --- a/examples/imageload_tilegrid_inflator_simpletest.py +++ b/examples/imageload_tilegrid_inflator_simpletest.py @@ -11,7 +11,7 @@ group = displayio.Group() group.append(tile_grid) -board.DISPLAY.show(group) +board.DISPLAY.root_group = group while True: pass From 6b0112f14e07006341addbca758d3e49e9bedf67 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 9 Nov 2023 14:07:19 -0500 Subject: [PATCH 053/111] Update README.rst to not use .show(...) --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e36bf51..8d7124a 100644 --- a/README.rst +++ b/README.rst @@ -40,8 +40,7 @@ Usage Example group = displayio.Group() group.append(tile_grid) - board.DISPLAY.show(group) - + board.DISPLAY.root_group = group while True: pass From 7bd6c813452469d2aeef1d3e22d4e1628b00634f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 4 Dec 2023 14:08:08 -0600 Subject: [PATCH 054/111] unpin sphinx and add sphinx-rtd-theme to docs reqs --- docs/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 797aa04..979f568 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Unlicense -sphinx>=4.0.0 +sphinx sphinxcontrib-jquery +sphinx-rtd-theme From 30f3e71827c6e14b4cf3fa2a59b3f1301e74a528 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Fri, 19 Jul 2024 15:13:42 -0500 Subject: [PATCH 055/111] Initial Commit Add support for JPG files using a wrapper that implements the jpegio library. --- adafruit_imageload/jpg.py | 0 examples/imageload_jpg_simpletest.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 adafruit_imageload/jpg.py create mode 100644 examples/imageload_jpg_simpletest.py diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/imageload_jpg_simpletest.py b/examples/imageload_jpg_simpletest.py new file mode 100644 index 0000000..e69de29 From 0e2c51241ac55a8bcfe091b46ac2011c631f2d04 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Mon, 22 Jul 2024 12:28:53 -0500 Subject: [PATCH 056/111] JPG Reading Implemented Added a JPG module that calls jpegio and updated the base __init__.py to recognize JPG files. --- adafruit_imageload/__init__.py | 5 +++++ adafruit_imageload/jpg.py | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index bd8cd98..38524e3 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -68,6 +68,7 @@ def load( with open_file as file: header = file.read(3) file.seek(0) + print(header) if header.startswith(b"BM"): from . import bmp @@ -89,4 +90,8 @@ def load( from . import png return png.load(file, bitmap=bitmap, palette=palette) + if header.startswith(b"\xff\xd8"): + from . import jpg + + return jpg.load(file, bitmap=bitmap, palette=palette) raise RuntimeError("Unsupported image format") diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py index e69de29..e2ae895 100644 --- a/adafruit_imageload/jpg.py +++ b/adafruit_imageload/jpg.py @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2024 Channing Ramos +# +# SPDX-License-Identifier: MIT + +""" +`adafruit_imageload.jpg` +==================================================== + +Load a JPG into a bitmap by calling jpegio. + +* Author(s): Channing Ramos + +""" + +#A separate try for jpegio. While it has wide support it is not universal, and this import may fail. +#If that happens an ImportError with a proper message needs to be raised +try: + from jpegio import JpegDecoder +except ImportError: + print("jpegio not supported on this board.") + +try: + from io import BufferedReader + from typing import Tuple, Iterator, Optional, List + from .displayio_types import PaletteConstructor, BitmapConstructor +except ImportError: + pass + +from displayio import Bitmap, ColorConverter, Colorspace + +def load(file: BufferedReader, + *, + bitmap: BitmapConstructor, + palette: Optional[PaletteConstructor] = None) -> Tuple[Bitmap, Optional[ColorConverter]]: + + decoder = JpegDecoder() + width, height = decoder.open(file) + bitmap_obj = bitmap(width, height, 65535) + decoder.decode(bitmap_obj) + + return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED) \ No newline at end of file From dbb20f58fddc696959497825a01ac27c48174477 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Mon, 22 Jul 2024 16:04:40 -0500 Subject: [PATCH 057/111] Removed palette option from load function Removed the palette option from the load function since it isnt used, as we use colorconverter instead. --- adafruit_imageload/__init__.py | 3 +-- adafruit_imageload/jpg.py | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 38524e3..0a54f68 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -68,7 +68,6 @@ def load( with open_file as file: header = file.read(3) file.seek(0) - print(header) if header.startswith(b"BM"): from . import bmp @@ -93,5 +92,5 @@ def load( if header.startswith(b"\xff\xd8"): from . import jpg - return jpg.load(file, bitmap=bitmap, palette=palette) + return jpg.load(file, bitmap=bitmap) raise RuntimeError("Unsupported image format") diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py index e2ae895..4570ee9 100644 --- a/adafruit_imageload/jpg.py +++ b/adafruit_imageload/jpg.py @@ -6,7 +6,7 @@ `adafruit_imageload.jpg` ==================================================== -Load a JPG into a bitmap by calling jpegio. +Load a JPG into a bitmap by calling the jpegio class. * Author(s): Channing Ramos @@ -21,21 +21,34 @@ try: from io import BufferedReader - from typing import Tuple, Iterator, Optional, List - from .displayio_types import PaletteConstructor, BitmapConstructor + from typing import Tuple, Optional + from .displayio_types import BitmapConstructor except ImportError: pass from displayio import Bitmap, ColorConverter, Colorspace +__version__ = "0.0.0+auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" + def load(file: BufferedReader, *, bitmap: BitmapConstructor, - palette: Optional[PaletteConstructor] = None) -> Tuple[Bitmap, Optional[ColorConverter]]: - + ) -> Tuple[Bitmap, Optional[ColorConverter]]: + """ + Loads a JPG image from the open ''file''. + The JPG must be a Baseline JPG, Progressive and Lossless JPG formats are not supported. + + Returns tuple of bitmap object and ColorConverter object. + + :param io.BufferedReader file: Open file handle or compatible (like 'io.BytesIO') + :param object bitmap: Type to store bitmap data. + Must have API similar to 'displayio.Bitmap'. Will be skipped if None. + Will be skipped if None. + """ decoder = JpegDecoder() width, height = decoder.open(file) bitmap_obj = bitmap(width, height, 65535) decoder.decode(bitmap_obj) - return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED) \ No newline at end of file + return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED) From 41a28c13676595879326e3e6e185215ff76d8ecf Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Mon, 22 Jul 2024 16:32:07 -0500 Subject: [PATCH 058/111] Simpletest completed. Completed the simpletest example script, along with a provided jpg. --- examples/imageload_jpg_simpletest.py | 18 ++++++++++++++++++ examples/images/jpg_test.jpg | Bin 0 -> 5465 bytes examples/images/jpg_test.jpg.license | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 examples/images/jpg_test.jpg create mode 100644 examples/images/jpg_test.jpg.license diff --git a/examples/imageload_jpg_simpletest.py b/examples/imageload_jpg_simpletest.py index e69de29..22d5e05 100644 --- a/examples/imageload_jpg_simpletest.py +++ b/examples/imageload_jpg_simpletest.py @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2024 Channing Ramos +# +# SPDX-License-Identifier: MIT + +import board +import displayio +import adafruit_imageload + +group = displayio.Group() +board.DISPLAY.root_group = group + +image, color_converter = adafruit_imageload.load("images/jpg_test.jpg") + +tile_grid = displayio.TileGrid(image, pixel_shader=color_converter) +group.append(tile_grid) + +while True: + pass diff --git a/examples/images/jpg_test.jpg b/examples/images/jpg_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7479826e16a4c5440dedc123f0fecf48f4d4e8a5 GIT binary patch literal 5465 zcmbW3XH*kyw}u}=M?mRKiUQI>x*`yY^j<H&PUPPMo4sR3$BnpHQ zib#_phyv1k&k26#eDC+;yywT+vnF$`z4v|3JbUI@E4VS-EV!htuB8qL@F7ef3;=Ep zQmv(`YHMh0psuB>hA#jBdF|og=}V*pfG5(=$5=y!%fj*w7wIA(1$6j>8A#hZ_Y_?*zcG$hp@)w*Bt~Dn}<@2LK4T@MR?jZy!HA+u>Q}zMuCwr{S62!NuMY z&*gX)_Q5|Op2yDfcmKsJ=j{B4A$SDzKBmU1__fjFnalY<`0jtOgNu(RzDEk*!{g|Q z#QQ@m{>6^x9CXf}9{%`e`xECYq;x{UOz>A8{COE@04<;g3;`Fo3;cmA@Bn^51b;>1 zGrqtWUsw4DJ?kI6AzpPCuW|(rc*Skt1w4WMA3ZpK2lyU*{5@M=grvlu6al3Q0L0Tc z+%_)&q{#rBzQEy*^KiJ+HvkZR1E3B0x8CbD05^8=`4@lZcya-__ymAP^xwI=sQ@%Z z0l+-&ZSQ0M=RSn^UkCyLz*aE;RF(kH4FEs^|JU5`wevd29|gb^KP%ln0Mau6xaN%a zw)%&4li>ybp4f(do>UAUaAV|CQ=47vN(Qcyw`wK0zc=06QW_{#<1}tB z5v8SWtCf?jQKU^6FTDDDW@QOGFBadE`JK;iReH1DI%yzhUOm8QGnt89AP7Es-tlIgrXY>w@^$ke8M&1NR#D$mLs%a z>x|j_mLtl%-Yp_$l&|q|)SIyWYPi4)1!DFhJw#r(t)YT`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S#L~o{qRolz%XFk`KLz)<5y$jERln>-NwK%KoeO*X3A4 z;@F)&x0Q(){`=YKU!l2iG+8^SITW=?n#V*Va-sg76;eHt@}%+Aq}F0c-%?JDKuJH% z2dUDl3d*NFg1{-9KAfvps0$-Bkl*6G>vkz1#&|dPRL_$}9D16tK;c*5D%U;XpImWm zIndG1t_u@7TLv@^In4z11QP`L9}co2;||RQ4vgF1%!}3t}zSC=u43Vbl?9Wmi*Aq2*Mf zbpKBEl3|o>XSHB|dx~g?;>~m>N?+&P^>wMNA1-T32A-s6UtT6*Cz|$%UPPN_?pk@> zoTpw0qUz62+-g)x?!B+0gKjaQavbXKqx^igg*riwH|?tuLpA*9S!=pFl{WeIH}%); zlG6hS?AgRrK(6oAHgTmkBid(eBz9HHIPkcfCM^&pvx!YM#;VbIXsE|U&XRDTWjo!} zqN*<(?MoC~7lsmtgf&RRkR!A=aX`&5Oo>?gxL@*!KB>tCEwI>JKkFfm0*2(FrB|fs zE_byinN8er$&fKSdm0^yEDC=dA!UHoR0y@{4tZyO9|WuV_wr*YhZCwn^~xY7DR^;e z$GVj`j6fl(_RXHgC~9UaWz0D38L5fx^zO^shgzP4ne{a(4MG`5{em4dD$^LfR8-iA z%Eu%bG{j`pSMe)L(d9uLu;Vq0*%ez(-V);GCm{D-QAi!*Xy-bR3NAT(W-z+5oCxRJ zegA@!u8<)u^%SZCJGBnBAfYP0;URe7**8z9pQGOWTjdPZ>rzWP-)KrJSa_kwTx!|b zQ|x{w(v-@MH3`)ZClZJ2w_f;Fy?KP1+UrL>5tp#vEn9<+>ZR-stS}hqmO+NkYRoc^ y>z`fu=)4tw0p{y{Fkjdd7pNwaEcJ2RM1mQk&62(-CbzTTNHJoh)}m~S8~-n2-fw~c literal 0 HcmV?d00001 diff --git a/examples/images/jpg_test.jpg.license b/examples/images/jpg_test.jpg.license new file mode 100644 index 0000000..ea30990 --- /dev/null +++ b/examples/images/jpg_test.jpg.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2024 Channing Ramos +# SPDX-License-Identifier: MIT \ No newline at end of file From 72e7ae25afa91af9c78f4c3b8f814b1bee9ea043 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 <134003603+ch4nsuk3@users.noreply.github.com> Date: Tue, 23 Jul 2024 17:19:14 -0500 Subject: [PATCH 059/111] Corrected Actions Errors Disabled the too-many-branches pylint check in __init__.py The new 'if' statement goes over the limit of 12 branches. Shortened comment in jpg.py --- adafruit_imageload/__init__.py | 1 + adafruit_imageload/jpg.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 0a54f68..3f632a6 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -47,6 +47,7 @@ def load( palette is the desired palette type. The constructor should take the number of colors and support assignment to indices via []. """ + # pylint: disable=too-many-branches if not bitmap or not palette: try: # use displayio if available diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py index 4570ee9..3101b37 100644 --- a/adafruit_imageload/jpg.py +++ b/adafruit_imageload/jpg.py @@ -12,7 +12,7 @@ """ -#A separate try for jpegio. While it has wide support it is not universal, and this import may fail. +#A separate try for jpegio. Not every board supports it and this import may fail. #If that happens an ImportError with a proper message needs to be raised try: from jpegio import JpegDecoder From 63779103dcaa661c6be7748a98e795b0d7f245ac Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Thu, 25 Jul 2024 14:23:28 -0500 Subject: [PATCH 060/111] Re-ran Black locally Formatting errors in jpg.py should be corrected now. PyCharm was using CRLF instead of LF line separators. --- adafruit_imageload/jpg.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py index 3101b37..9af3d60 100644 --- a/adafruit_imageload/jpg.py +++ b/adafruit_imageload/jpg.py @@ -12,8 +12,8 @@ """ -#A separate try for jpegio. Not every board supports it and this import may fail. -#If that happens an ImportError with a proper message needs to be raised +# A separate try for jpegio. Not every board supports it and this import may fail. +# If that happens an ImportError with a proper message needs to be raised try: from jpegio import JpegDecoder except ImportError: @@ -31,10 +31,12 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load(file: BufferedReader, - *, - bitmap: BitmapConstructor, - ) -> Tuple[Bitmap, Optional[ColorConverter]]: + +def load( + file: BufferedReader, + *, + bitmap: BitmapConstructor, +) -> Tuple[Bitmap, Optional[ColorConverter]]: """ Loads a JPG image from the open ''file''. The JPG must be a Baseline JPG, Progressive and Lossless JPG formats are not supported. From 9b9cbf41fda9e23caa5542b3f2c9ad8782ece871 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Thu, 25 Jul 2024 14:34:26 -0500 Subject: [PATCH 061/111] Missed Files Helps if I include them all. --- examples/imageload_jpg_simpletest.py | 4 ++++ examples/images/jpg_test.jpg.license | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/imageload_jpg_simpletest.py b/examples/imageload_jpg_simpletest.py index 22d5e05..dc4b8ef 100644 --- a/examples/imageload_jpg_simpletest.py +++ b/examples/imageload_jpg_simpletest.py @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: MIT +""" +Basic JPG imageload example +""" + import board import displayio import adafruit_imageload diff --git a/examples/images/jpg_test.jpg.license b/examples/images/jpg_test.jpg.license index ea30990..d2f8702 100644 --- a/examples/images/jpg_test.jpg.license +++ b/examples/images/jpg_test.jpg.license @@ -1,2 +1,2 @@ # SPDX-FileCopyrightText: 2024 Channing Ramos -# SPDX-License-Identifier: MIT \ No newline at end of file +# SPDX-License-Identifier: MIT From 3a6248361216294cc2a3492f2455ab6bcf1af96c Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Fri, 26 Jul 2024 18:19:56 -0500 Subject: [PATCH 062/111] Initial Testing Initial testing of the transparency block. --- adafruit_imageload/png.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 34b32f0..93d0e21 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -61,6 +61,10 @@ def load( height = 0 while True: size, chunk = struct.unpack(">I4s", file.read(8)) + print("==================") + print(size) + print(chunk) + print('====================') if chunk == b"IHDR": ( width, @@ -86,6 +90,9 @@ def load( pal = palette(pal_size) for i in range(pal_size): pal[i] = file.read(3) + elif chunk == b"tRNS": + transparent = file.read(size) + print(transparent) elif chunk == b"IDAT": data.extend(file.read(size)) elif chunk == b"IEND": From 0aed0e9c1ccd84085e3f6fa545ad82112064dd52 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 <134003603+ch4nsuk3@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:02:30 -0500 Subject: [PATCH 063/111] Initial Implementation Transparency checking works, but there still may be efficient methods. --- adafruit_imageload/png.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 93d0e21..130579c 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -61,10 +61,6 @@ def load( height = 0 while True: size, chunk = struct.unpack(">I4s", file.read(8)) - print("==================") - print(size) - print(chunk) - print('====================') if chunk == b"IHDR": ( width, @@ -91,8 +87,10 @@ def load( for i in range(pal_size): pal[i] = file.read(3) elif chunk == b"tRNS": - transparent = file.read(size) - print(transparent) + trns_list = list(file.read(size)) + indices = [i for i, x in enumerate(trns_list) if x == 0] + for index in indices: + pal.make_transparent(index) elif chunk == b"IDAT": data.extend(file.read(size)) elif chunk == b"IEND": From ce523ff41fe4446f0d2926815a55391b2c424570 Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Thu, 1 Aug 2024 15:41:56 -0500 Subject: [PATCH 064/111] Final Implementation Various testing shows using a for loop is the quickest method, beating enumeration and list comprehension. --- adafruit_imageload/png.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 130579c..8e0d481 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -48,7 +48,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") @@ -87,10 +87,12 @@ def load( for i in range(pal_size): pal[i] = file.read(3) elif chunk == b"tRNS": - trns_list = list(file.read(size)) - indices = [i for i, x in enumerate(trns_list) if x == 0] - for index in indices: - pal.make_transparent(index) + 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) elif chunk == b"IDAT": data.extend(file.read(size)) elif chunk == b"IEND": From a8809b03a6f40a2f96402d5ec9d864edddc5f27e Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Thu, 1 Aug 2024 15:44:40 -0500 Subject: [PATCH 065/111] Updated author info --- adafruit_imageload/png.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 8e0d481..870313c 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -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 """ From a7ac0db3a7f5c39808718afe165b7a2f1a985dbb Mon Sep 17 00:00:00 2001 From: ch4nsuk3 Date: Fri, 2 Aug 2024 16:24:59 -0500 Subject: [PATCH 066/111] Del trans_data Deletes the trans_data list after its no longer needed. --- adafruit_imageload/png.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 870313c..dbc0abf 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -94,6 +94,7 @@ def load( 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": From 8e6af9bdd08a317978e4a2aa7881459e1b2ff050 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 3 Aug 2024 02:38:56 +0200 Subject: [PATCH 067/111] Add support for RGB, RGBA and Grayscale PNGs This adds support for filters, which lets us decode grayscale and RGB images. I only support 8bit depth for now (and 24bit for RGB) but with better color conversion code, other depths could be supported. --- adafruit_imageload/png.py | 83 ++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index dbc0abf..2c302f1 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -49,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, consider-using-enumerate, too-many-statements + # pylint: disable=too-many-locals, too-many-branches, consider-using-enumerate, too-many-statements, import-outside-toplevel, invalid-name header = file.read(8) if header != b"\x89PNG\r\n\x1a\n": raise ValueError("Not a PNG file") @@ -103,15 +103,80 @@ def load( file.seek(size, 1) # skip unknown chunks file.seek(4, 1) # skip CRC data_bytes = zlib.decompress(data) - bmp = bitmap(width, height, 1 << depth) - scanline = (width * depth + 7) // 8 - mem = memoryview(bmp) + unit = (1, 0, 3, 1, 2, 0, 4)[mode] + scanline = (width * depth * unit + 7) // 8 + colors = 1 << (depth * unit) + if mode == 3: # indexed + bmp = bitmap(width, height, colors) + mem = memoryview(bmp) + for y in range(height): + dst = y * scanline + src = y * (scanline + 1) + 1 + mem[dst : dst + scanline] = data_bytes[src : src + scanline] + return bmp, pal + # RGB, RGBA or Grayscale + import displayio + + if depth != 8: + raise ValueError("Must be 8bit depth.") + pal = displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB888) + bmp = bitmap(width, height, 65536) + prev = bytearray(scanline) + line = bytearray(scanline) for y in range(height): - dst = y * scanline - src = y * (scanline + 1) + 1 - filter_ = data_bytes[src - 1] + src = y * (scanline + 1) + filter_ = data_bytes[src] + src += 1 if filter_ == 0: - mem[dst : dst + scanline] = data_bytes[src : src + scanline] + line[0:scanline] = data_bytes[src : src + scanline] + elif filter_ == 1: # sub + for i in range(scanline): + a = line[i - unit] if i >= unit else 0 + line[i] = (data_bytes[src] + a) & 0xFF + src += 1 + elif filter_ == 2: # up + for i in range(scanline): + b = prev[i] + line[i] = (data_bytes[src] + b) & 0xFF + src += 1 + elif filter_ == 3: # average + for i in range(scanline): + a = line[i - unit] if i >= unit else 0 + b = prev[i] + line[i] = (data_bytes[src] + ((a + b) >> 1)) & 0xFF + src += 1 + elif filter_ == 4: # paeth + for i in range(scanline): + a = line[i - unit] if i >= unit else 0 + b = prev[i] + c = prev[i - unit] if i >= unit else 0 + p = a + b - c + pa = abs(p - a) + pb = abs(p - b) + pc = abs(p - c) + if pa <= pb and pa <= pc: + p = a + elif pb <= pc: + p = b + else: + p = c + line[i] = (data_bytes[src] + p) & 0xFF + src += 1 + else: + raise ValueError("Wrong filter.") + prev, line = line, prev + if mode in (0, 4): # grayscale + for x in range(width): + c = line[x * unit] + bmp[x, y] = pal.convert((c << 16) | (c << 8) | c) + elif mode in {2, 6}: # rgb + for x in range(width): + bmp[x, y] = pal.convert( + (line[x * unit + 0] << 16) + | (line[x * unit + 1] << 8) + | line[x * unit + 2] + ) else: - raise NotImplementedError("Filters not supported") + raise ValueError("Unsupported color mode.") + pal = displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565) return bmp, pal From 349529978c607bc4added21642594a98d96babe6 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sat, 3 Aug 2024 16:35:02 +0200 Subject: [PATCH 068/111] Fix #74 Add a workaround for bug https://github.com/adafruit/circuitpython/issues/6675 and use bitmap[x, y] instead of putting data into the bitmap directly through the memoryview for bit depths < 8. --- adafruit_imageload/png.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 2c302f1..404d503 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -112,7 +112,19 @@ def load( for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - mem[dst : dst + scanline] = data_bytes[src : src + scanline] + if depth < 8: + # Work around the bug in displayio.Bitmap + # https://github.com/adafruit/circuitpython/issues/6675 + pixels_per_byte = 8 // depth + for x in range(0, width, pixels_per_byte): + byte = data_bytes[src] + for pixel in range(pixels_per_byte): + bmp[x + pixel, y] = ( + byte >> ((pixels_per_byte - pixel - 1) * depth) + ) & ((1 << depth) - 1) + src += 1 + else: + mem[dst : dst + scanline] = data_bytes[src : src + scanline] return bmp, pal # RGB, RGBA or Grayscale import displayio From 7469a784f1c0fb26124c56760397169a099e41c3 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 3 Aug 2024 11:21:24 -0500 Subject: [PATCH 069/111] use ruff. add optional different format types to png example --- .gitattributes | 5 + .pre-commit-config.yaml | 42 +- .pylintrc | 399 ------------------ README.rst | 6 +- adafruit_imageload/__init__.py | 18 +- adafruit_imageload/bmp/__init__.py | 11 +- adafruit_imageload/bmp/indexed.py | 22 +- adafruit_imageload/bmp/truecolor.py | 22 +- adafruit_imageload/displayio_types.py | 4 +- adafruit_imageload/gif.py | 32 +- adafruit_imageload/jpg.py | 3 +- adafruit_imageload/png.py | 24 +- adafruit_imageload/pnm/__init__.py | 26 +- adafruit_imageload/pnm/pbm_ascii.py | 5 +- adafruit_imageload/pnm/pbm_binary.py | 6 +- adafruit_imageload/pnm/pgm/__init__.py | 12 +- adafruit_imageload/pnm/pgm/ascii.py | 13 +- adafruit_imageload/pnm/pgm/binary.py | 13 +- adafruit_imageload/pnm/ppm_ascii.py | 12 +- adafruit_imageload/pnm/ppm_binary.py | 10 +- adafruit_imageload/tilegrid_inflator.py | 11 +- docs/conf.py | 8 +- examples/imageload_colorwheel.py | 1 + examples/imageload_from_web.py | 11 +- examples/imageload_jpg_simpletest.py | 1 + examples/imageload_magtag_simpletest.py | 3 + examples/imageload_netpbm.py | 7 +- examples/imageload_png_simpletest.py | 10 +- examples/imageload_simpletest.py | 1 + .../imageload_tilegrid_inflator_simpletest.py | 1 + examples/images/test_image_2bit.png.license | 2 + .../images/test_image_grayscale.png.license | 2 + examples/images/test_image_rgb.png.license | 2 + ruff.toml | 99 +++++ tests/displayio_shared_bindings.py | 26 +- tests/test_bitmap_c_interface.py | 12 +- tests/test_bmp_indexed_load.py | 6 +- tests/test_palette_c_interface.py | 18 +- tests/test_pbm_load.py | 13 +- tests/test_pgm_load.py | 3 + tests/test_ppm_load.py | 3 + 41 files changed, 308 insertions(+), 617 deletions(-) create mode 100644 .gitattributes delete mode 100644 .pylintrc create mode 100644 examples/images/test_image_2bit.png.license create mode 100644 examples/images/test_image_grayscale.png.license create mode 100644 examples/images/test_image_rgb.png.license create mode 100644 ruff.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d54c593 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + +* text eol=lf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70ade69..f27b786 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,42 +1,22 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2024 Justin Myers # # SPDX-License-Identifier: Unlicense repos: - - repo: https://github.com/python/black - rev: 23.3.0 - hooks: - - id: black - - repo: https://github.com/fsfe/reuse-tool - rev: v1.1.2 - hooks: - - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/pycqa/pylint - rev: v2.17.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 hooks: - - id: pylint - name: pylint (library code) - types: [python] - args: - - --disable=consider-using-f-string - exclude: "^(docs/|examples/|tests/|setup.py$)" - - id: pylint - name: pylint (example code) - description: Run pylint rules on "examples/*.py" files - types: [python] - files: "^examples/" - args: - - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - - id: pylint - name: pylint (test code) - description: Run pylint rules on "tests/*.py" files - types: [python] - files: "^tests/" - args: - - --disable=missing-docstring,consider-using-f-string,duplicate-code + - id: ruff-format + - id: ruff + args: ["--fix"] + - repo: https://github.com/fsfe/reuse-tool + rev: v3.0.1 + hooks: + - id: reuse diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index f945e92..0000000 --- a/.pylintrc +++ /dev/null @@ -1,399 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# -# SPDX-License-Identifier: Unlicense - -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Add files or directories to the ignore-list. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the ignore-list. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins=pylint.extensions.no_self_use - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call -disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -# notes=FIXME,XXX,TODO -notes=FIXME,XXX - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=board - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -# expected-line-ending-format= -expected-line-ending-format=LF - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=12 - - -[BASIC] - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class names -# class-rgx=[A-Z_][a-zA-Z0-9]+$ -class-rgx=[A-Z_][a-zA-Z0-9_]+$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -# good-names=i,j,k,ex,Run,_ -good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -# max-attributes=7 -max-attributes=11 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=1 - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception diff --git a/README.rst b/README.rst index 8d7124a..c698f93 100644 --- a/README.rst +++ b/README.rst @@ -13,9 +13,9 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad/actions/ :alt: Build Status -.. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/psf/black - :alt: Code Style: Black +.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: https://github.com/astral-sh/ruff + :alt: Code Style: Ruff This library decodes an image file into new bitmap and palette objects of the provided type. It's designed to load code needed during decoding as needed. This is meant to minimize the memory diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index 3f632a6..bf7d3e2 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -12,20 +12,21 @@ * Author(s): Scott Shawcroft, Matt Land """ -# pylint: disable=import-outside-toplevel try: + from io import BufferedReader from typing import ( - Tuple, + Iterable, Iterator, - Optional, List, - Iterable, + Optional, + Tuple, Union, ) - from io import BufferedReader - from displayio import Palette, Bitmap - from .displayio_types import PaletteConstructor, BitmapConstructor + + from displayio import Bitmap, Palette + + from .displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -37,7 +38,7 @@ def load( file_or_filename: Union[str, BufferedReader], *, bitmap: Optional[BitmapConstructor] = None, - palette: Optional[PaletteConstructor] = None + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Bitmap, Optional[Palette]]: """Load pixel values (indices or colors) into a bitmap and colors into a palette. @@ -47,7 +48,6 @@ def load( palette is the desired palette type. The constructor should take the number of colors and support assignment to indices via []. """ - # pylint: disable=too-many-branches if not bitmap or not palette: try: # use displayio if available diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index 56d9b7c..d7b9801 100755 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -12,13 +12,14 @@ * Author(s): Scott Shawcroft, Matt Land """ -# pylint: disable=import-outside-toplevel try: - from typing import Tuple, Optional, Set, List from io import BufferedReader - from displayio import Palette, Bitmap - from ..displayio_types import PaletteConstructor, BitmapConstructor + from typing import List, Optional, Set, Tuple + + from displayio import Bitmap, Palette + + from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -30,7 +31,7 @@ def load( file: BufferedReader, *, bitmap: Optional[BitmapConstructor] = None, - palette: Optional[PaletteConstructor] = None + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """Loads a bmp image from the open ``file``. diff --git a/adafruit_imageload/bmp/indexed.py b/adafruit_imageload/bmp/indexed.py index 134b9b3..8168921 100755 --- a/adafruit_imageload/bmp/indexed.py +++ b/adafruit_imageload/bmp/indexed.py @@ -13,28 +13,29 @@ """ - import sys try: - from typing import Tuple, Optional from io import BufferedReader - from displayio import Palette, Bitmap - from ..displayio_types import PaletteConstructor, BitmapConstructor + from typing import Optional, Tuple + + from displayio import Bitmap, Palette + + from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass try: from bitmaptools import readinto as _bitmap_readinto except ImportError: - _bitmap_readinto = None # pylint: disable=invalid-name # type: Callable + _bitmap_readinto = None __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load( +def load( # noqa: PLR0913, PLR0912, Too many arguments in function definition, Too many branches file: BufferedReader, width: int, height: int, @@ -58,7 +59,6 @@ def load( :param BitmapConstructor bitmap: a function that returns a displayio.Bitmap :param PaletteConstructor palette: a function that returns a displayio.Palette """ - # pylint: disable=too-many-arguments,too-many-locals,too-many-branches palette_obj = None if palette: palette_obj = palette(colors) @@ -78,7 +78,6 @@ def load( minimum_color_depth *= 2 if sys.maxsize > 1073741823: - # pylint: disable=import-outside-toplevel, relative-beyond-top-level from .negative_height_check import negative_height_check # convert unsigned int to signed int when height is negative @@ -121,9 +120,7 @@ def load( for x in range(width): i = x // pixels_per_byte - pixel = ( - chunk[i] >> (8 - color_depth * (x % pixels_per_byte + 1)) - ) & mask + pixel = (chunk[i] >> (8 - color_depth * (x % pixels_per_byte + 1))) & mask bitmap_obj[offset + x] = pixel elif compression in (1, 2): decode_rle( @@ -137,7 +134,7 @@ def load( return bitmap_obj, palette_obj -def decode_rle( +def decode_rle( # noqa: PLR0912 Too many branches bitmap: Bitmap, file: BufferedReader, compression: int, @@ -145,7 +142,6 @@ def decode_rle( width: int, ) -> None: """Helper to decode RLE images""" - # pylint: disable=too-many-locals,too-many-nested-blocks,too-many-branches # RLE algorithm, either 8-bit (1) or 4-bit (2) # diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py index b1b0889..1e6dccd 100755 --- a/adafruit_imageload/bmp/truecolor.py +++ b/adafruit_imageload/bmp/truecolor.py @@ -16,13 +16,14 @@ import sys try: - from typing import Union, Optional, Tuple from io import BufferedReader + from typing import Optional, Tuple, Union + from ..displayio_types import BitmapConstructor except ImportError: pass -from displayio import ColorConverter, Colorspace, Bitmap +from displayio import Bitmap, ColorConverter, Colorspace __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" @@ -52,7 +53,7 @@ def bitfield_format(bitfield_mask): return None -def load( +def load( # noqa: PLR0912, PLR0913, Too many branches, Too many arguments in function definition file: BufferedReader, width: int, height: int, @@ -73,7 +74,6 @@ def load( :param dict bitfield_masks: The bitfield masks for each color if using bitfield compression :param BitmapConstructor bitmap: a function that returns a displayio.Bitmap """ - # pylint: disable=too-many-arguments,too-many-locals,too-many-branches converter_obj = None bitmap_obj = None if bitmap: @@ -90,7 +90,6 @@ def load( input_colorspace = Colorspace.RGB555 converter_obj = ColorConverter(input_colorspace=input_colorspace) if sys.maxsize > 1073741823: - # pylint: disable=import-outside-toplevel, relative-beyond-top-level from .negative_height_check import negative_height_check # convert unsigned int to signed int when height is negative @@ -119,19 +118,14 @@ def load( color = 0 for byte in range(bytes_per_pixel): color |= chunk[i + byte] << (8 * byte) - mask = ( - bitfield_masks["red"] - | bitfield_masks["green"] - | bitfield_masks["blue"] - ) + mask = bitfield_masks["red"] | bitfield_masks["green"] | bitfield_masks["blue"] if color_depth in (24, 32): mask = mask >> 8 pixel = color & mask + elif color_depth == 16: + pixel = chunk[i] | chunk[i + 1] << 8 else: - if color_depth == 16: - pixel = chunk[i] | chunk[i + 1] << 8 - else: - pixel = chunk[i + 2] << 16 | chunk[i + 1] << 8 | chunk[i] + pixel = chunk[i + 2] << 16 | chunk[i + 1] << 8 | chunk[i] bitmap_obj[offset + x] = converter_obj.convert(pixel) return bitmap_obj, ColorConverter(input_colorspace=Colorspace.RGB565) diff --git a/adafruit_imageload/displayio_types.py b/adafruit_imageload/displayio_types.py index c46006a..f2adcc7 100644 --- a/adafruit_imageload/displayio_types.py +++ b/adafruit_imageload/displayio_types.py @@ -13,9 +13,11 @@ * Author(s): Matt Land """ + try: from typing import Callable - from displayio import Palette, Bitmap + + from displayio import Bitmap, Palette PaletteConstructor = Callable[[int], Palette] BitmapConstructor = Callable[[int, int, int], Bitmap] diff --git a/adafruit_imageload/gif.py b/adafruit_imageload/gif.py index f1a05e4..e5183c1 100644 --- a/adafruit_imageload/gif.py +++ b/adafruit_imageload/gif.py @@ -17,10 +17,12 @@ import struct try: - from typing import Tuple, Iterator, Optional, List from io import BufferedReader - from displayio import Palette, Bitmap - from .displayio_types import PaletteConstructor, BitmapConstructor + from typing import Iterator, List, Optional, Tuple + + from displayio import Bitmap, Palette + + from .displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -29,10 +31,7 @@ def load( - file: BufferedReader, - *, - bitmap: BitmapConstructor, - palette: Optional[PaletteConstructor] = None + file: BufferedReader, *, bitmap: BitmapConstructor, palette: Optional[PaletteConstructor] = None ) -> Tuple[Bitmap, Optional[Palette]]: """Loads a GIF image from the open ``file``. @@ -47,9 +46,7 @@ def load( header = file.read(6) if header not in {b"GIF87a", b"GIF89a"}: raise ValueError("Not a GIF file") - width, height, flags, _, _ = struct.unpack( # pylint: disable=no-member - " None: """Read a single frame and apply it to the bitmap.""" - ddx, ddy, width, _, flags = struct.unpack( # pylint: disable=no-member - " bytes: value = self.last + self.last[0:1] if self.last: self.codes.append(self.last + value[0:1]) - if ( - len(self.codes) + self.end_code + 1 >= 1 << self.code_len - and self.code_len < 12 - ): + if len(self.codes) + self.end_code + 1 >= 1 << self.code_len and self.code_len < 12: self.code_len += 1 self.last = value return value @@ -159,7 +151,7 @@ def lzw_decode(data: Iterator[int], code_size: int) -> Iterator[bytes]: dictionary = LZWDict(code_size) bit = 0 try: - byte = next(data) # pylint: disable=stop-iteration-return + byte = next(data) try: while True: code = 0 @@ -168,10 +160,10 @@ def lzw_decode(data: Iterator[int], code_size: int) -> Iterator[bytes]: bit += 1 if bit >= 8: bit = 0 - byte = next(data) # pylint: disable=stop-iteration-return + byte = next(data) yield dictionary.decode(code) except EndOfData: while True: - next(data) # pylint: disable=stop-iteration-return + next(data) except StopIteration: pass diff --git a/adafruit_imageload/jpg.py b/adafruit_imageload/jpg.py index 9af3d60..ad5174c 100644 --- a/adafruit_imageload/jpg.py +++ b/adafruit_imageload/jpg.py @@ -21,7 +21,8 @@ try: from io import BufferedReader - from typing import Tuple, Optional + from typing import Optional, Tuple + from .displayio_types import BitmapConstructor except ImportError: pass diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 404d503..84867b9 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -18,8 +18,10 @@ try: from io import BufferedReader from typing import Optional, Tuple - from displayio import Palette, Bitmap - from .displayio_types import PaletteConstructor, BitmapConstructor + + from displayio import Bitmap, Palette + + from .displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -30,11 +32,8 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load( - file: BufferedReader, - *, - bitmap: BitmapConstructor, - palette: Optional[PaletteConstructor] = None +def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements + file: BufferedReader, *, bitmap: BitmapConstructor, palette: Optional[PaletteConstructor] = None ) -> Tuple[Bitmap, Optional[Palette]]: """ Loads a PNG image from the open ``file``. @@ -49,7 +48,6 @@ 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, consider-using-enumerate, too-many-statements, import-outside-toplevel, invalid-name header = file.read(8) if header != b"\x89PNG\r\n\x1a\n": raise ValueError("Not a PNG file") @@ -119,9 +117,9 @@ def load( for x in range(0, width, pixels_per_byte): byte = data_bytes[src] for pixel in range(pixels_per_byte): - bmp[x + pixel, y] = ( - byte >> ((pixels_per_byte - pixel - 1) * depth) - ) & ((1 << depth) - 1) + bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( + (1 << depth) - 1 + ) src += 1 else: mem[dst : dst + scanline] = data_bytes[src : src + scanline] @@ -184,9 +182,7 @@ def load( elif mode in {2, 6}: # rgb for x in range(width): bmp[x, y] = pal.convert( - (line[x * unit + 0] << 16) - | (line[x * unit + 1] << 8) - | line[x * unit + 2] + (line[x * unit + 0] << 16) | (line[x * unit + 1] << 8) | line[x * unit + 2] ) else: raise ValueError("Unsupported color mode.") diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index 66b731d..7a18aeb 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -14,21 +14,22 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ -# pylint: disable=import-outside-toplevel try: + from io import BufferedReader from typing import ( - Tuple, + Callable, + Iterable, Iterator, - Optional, List, - Iterable, + Optional, + Tuple, Union, - Callable, ) - from io import BufferedReader - from displayio import Palette, Bitmap - from ..displayio_types import PaletteConstructor, BitmapConstructor + + from displayio import Bitmap, Palette + + from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -36,12 +37,12 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def load( +def load( # noqa: PLR0912 Too many branches file: BufferedReader, header: bytes, *, bitmap: Optional[BitmapConstructor] = None, - palette: Optional[PaletteConstructor] = None + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Scan for netpbm format info, skip over comments, and delegate to a submodule @@ -50,7 +51,6 @@ def load( All other formats have three: width, height, and max color value. This load function will move the file stream pointer to the start of data in all cases. """ - # pylint: disable=too-many-branches magic_number = header[:2] file.seek(2) pnm_header = [] # type: List[int] @@ -100,7 +100,7 @@ def load( palette_obj = None if palette: palette_obj = palette(1) - palette_obj[0] = b"\xFF\xFF\xFF" + palette_obj[0] = b"\xff\xff\xff" if magic_number.startswith(b"P1"): from . import pbm_ascii @@ -124,7 +124,7 @@ def load( next_byte = file.read(1) if next_byte == b"": - raise RuntimeError("Unsupported image format {!r}".format(magic_number)) + raise RuntimeError(f"Unsupported image format {magic_number!r}") if next_byte == b"#": # comment found, seek until a newline or EOF is found while file.read(1) not in [b"", b"\n"]: # EOF or NL pass diff --git a/adafruit_imageload/pnm/pbm_ascii.py b/adafruit_imageload/pnm/pbm_ascii.py index 0122132..872846c 100644 --- a/adafruit_imageload/pnm/pbm_ascii.py +++ b/adafruit_imageload/pnm/pbm_ascii.py @@ -17,9 +17,10 @@ """ try: - from typing import Tuple, Optional from io import BufferedReader - from displayio import Palette, Bitmap + from typing import Optional, Tuple + + from displayio import Bitmap, Palette except ImportError: pass diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index 263cb2c..cecdba5 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -15,10 +15,12 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ + try: - from typing import Tuple, Optional, Iterator from io import BufferedReader - from displayio import Palette, Bitmap + from typing import Iterator, Optional, Tuple + + from displayio import Bitmap, Palette except ImportError: pass diff --git a/adafruit_imageload/pnm/pgm/__init__.py b/adafruit_imageload/pnm/pgm/__init__.py index 3ed43f7..8acefb5 100644 --- a/adafruit_imageload/pnm/pgm/__init__.py +++ b/adafruit_imageload/pnm/pgm/__init__.py @@ -14,12 +14,14 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ -# pylint: disable=import-outside-toplevel + try: - from typing import Tuple, Optional, Set, List from io import BufferedReader - from displayio import Palette, Bitmap - from ...displayio_types import PaletteConstructor, BitmapConstructor + from typing import List, Optional, Set, Tuple + + from displayio import Bitmap, Palette + + from ...displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -30,7 +32,7 @@ def load( header: List[int], *, bitmap: Optional[BitmapConstructor] = None, - palette: Optional[PaletteConstructor] = None + palette: Optional[PaletteConstructor] = None, ) -> Tuple[Optional[Bitmap], Optional[Palette]]: """ Perform the load of Netpbm greyscale images (P2, P5) diff --git a/adafruit_imageload/pnm/pgm/ascii.py b/adafruit_imageload/pnm/pgm/ascii.py index 097665f..7c597ca 100644 --- a/adafruit_imageload/pnm/pgm/ascii.py +++ b/adafruit_imageload/pnm/pgm/ascii.py @@ -14,11 +14,14 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ + try: - from typing import Tuple, Set, Optional from io import BufferedReader - from displayio import Palette, Bitmap - from ...displayio_types import PaletteConstructor, BitmapConstructor + from typing import Optional, Set, Tuple + + from displayio import Bitmap, Palette + + from ...displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -66,9 +69,7 @@ def load( return bitmap_obj, palette_obj -def build_palette( - palette_class: PaletteConstructor, palette_colors: Set[int] -) -> Palette: # pylint: disable=duplicate-code +def build_palette(palette_class: PaletteConstructor, palette_colors: Set[int]) -> Palette: """ construct the Palette, and populate it with the set of palette_colors """ diff --git a/adafruit_imageload/pnm/pgm/binary.py b/adafruit_imageload/pnm/pgm/binary.py index 7e8c56b..700b563 100644 --- a/adafruit_imageload/pnm/pgm/binary.py +++ b/adafruit_imageload/pnm/pgm/binary.py @@ -14,11 +14,14 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ + try: - from typing import Tuple, Optional, Set from io import BufferedReader - from displayio import Palette, Bitmap - from ...displayio_types import PaletteConstructor, BitmapConstructor + from typing import Optional, Set, Tuple + + from displayio import Bitmap, Palette + + from ...displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -54,9 +57,7 @@ def load( return bitmap_obj, palette_obj -def build_palette( - palette_class: PaletteConstructor, palette_colors: Set[int] -) -> Palette: +def build_palette(palette_class: PaletteConstructor, palette_colors: Set[int]) -> Palette: """ construct the Palette, and populate it with the set of palette_colors """ diff --git a/adafruit_imageload/pnm/ppm_ascii.py b/adafruit_imageload/pnm/ppm_ascii.py index f6bb88b..e79b70b 100644 --- a/adafruit_imageload/pnm/ppm_ascii.py +++ b/adafruit_imageload/pnm/ppm_ascii.py @@ -20,16 +20,18 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" try: + from io import BufferedReader from typing import ( - Tuple, Iterator, - Optional, List, + Optional, Set, + Tuple, ) - from io import BufferedReader - from displayio import Palette, Bitmap - from ..displayio_types import PaletteConstructor, BitmapConstructor + + from displayio import Bitmap, Palette + + from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass diff --git a/adafruit_imageload/pnm/ppm_binary.py b/adafruit_imageload/pnm/ppm_binary.py index b726dc4..56540d3 100644 --- a/adafruit_imageload/pnm/ppm_binary.py +++ b/adafruit_imageload/pnm/ppm_binary.py @@ -15,11 +15,14 @@ * Author(s): Matt Land, Brooke Storm, Sam McGahan """ + try: - from typing import Tuple, Optional, Set from io import BufferedReader - from displayio import Palette, Bitmap - from ..displayio_types import PaletteConstructor, BitmapConstructor + from typing import Optional, Set, Tuple + + from displayio import Bitmap, Palette + + from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: pass @@ -38,7 +41,6 @@ def load( Load pixel values (indices or colors) into a bitmap and for a binary ppm, return None for pallet. """ - # pylint: disable=too-many-locals data_start = file.tell() palette_colors = set() # type: Set[Tuple[int, int, int]] diff --git a/adafruit_imageload/tilegrid_inflator.py b/adafruit_imageload/tilegrid_inflator.py index db6c65f..89a3458 100644 --- a/adafruit_imageload/tilegrid_inflator.py +++ b/adafruit_imageload/tilegrid_inflator.py @@ -13,12 +13,15 @@ * Author(s): Tim Cocks, Matt Land """ + import displayio + import adafruit_imageload try: - from typing import Tuple, Optional, List, Union - from displayio import Palette, Bitmap, OnDiskBitmap, TileGrid + from typing import List, Optional, Tuple, Union + + from displayio import Bitmap, OnDiskBitmap, Palette, TileGrid except ImportError: pass @@ -26,7 +29,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" -def inflate_tilegrid( +def inflate_tilegrid( # noqa: PLR0913, PLR0912, Too many arguments in function definition, Too many branches bmp_path: Optional[str] = None, target_size: Tuple[int, int] = (3, 3), tile_size: Optional[List[int]] = None, @@ -48,8 +51,6 @@ def inflate_tilegrid( :param Optional[Palette] bmp_palette: Already loaded spritesheet Palette """ - # pylint: disable=too-many-arguments, too-many-locals, too-many-branches - if bmp_path is None and (bmp_obj is None and bmp_palette is None): raise AttributeError("Must pass either bmp_path or bmp_obj and bmp_palette") diff --git a/docs/conf.py b/docs/conf.py index 86f66b4..7e8361c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- - # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # # SPDX-License-Identifier: MIT +import datetime import os import sys -import datetime sys.path.insert(0, os.path.abspath("..")) @@ -48,9 +46,7 @@ creation_year = "2018" current_year = str(datetime.datetime.now().year) year_duration = ( - current_year - if current_year == creation_year - else creation_year + " - " + current_year + current_year if current_year == creation_year else creation_year + " - " + current_year ) copyright = year_duration + " Scott Shawcroft" author = "Scott Shawcroft" diff --git a/examples/imageload_colorwheel.py b/examples/imageload_colorwheel.py index d43d378..58bc889 100644 --- a/examples/imageload_colorwheel.py +++ b/examples/imageload_colorwheel.py @@ -3,6 +3,7 @@ import board import displayio + import adafruit_imageload display = board.DISPLAY diff --git a/examples/imageload_from_web.py b/examples/imageload_from_web.py index 283eb59..9a873a8 100644 --- a/examples/imageload_from_web.py +++ b/examples/imageload_from_web.py @@ -4,14 +4,16 @@ imageload example for esp32s2 that loads an image fetched via adafruit_requests using BytesIO """ -from io import BytesIO + import ssl -import wifi -import socketpool +from io import BytesIO +import adafruit_requests as requests import board import displayio -import adafruit_requests as requests +import socketpool +import wifi + import adafruit_imageload # Get wifi details and more from a secrets.py file @@ -28,7 +30,6 @@ socket = socketpool.SocketPool(wifi.radio) https = requests.Session(socket, ssl.create_default_context()) -# pylint: disable=line-too-long url = "https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_ImageLoad/main/examples/images/4bit.bmp" print("Fetching text from %s" % url) diff --git a/examples/imageload_jpg_simpletest.py b/examples/imageload_jpg_simpletest.py index dc4b8ef..93f2a2f 100644 --- a/examples/imageload_jpg_simpletest.py +++ b/examples/imageload_jpg_simpletest.py @@ -8,6 +8,7 @@ import board import displayio + import adafruit_imageload group = displayio.Group() diff --git a/examples/imageload_magtag_simpletest.py b/examples/imageload_magtag_simpletest.py index ad95515..cbee121 100644 --- a/examples/imageload_magtag_simpletest.py +++ b/examples/imageload_magtag_simpletest.py @@ -5,9 +5,12 @@ Basic imageload example script adapted for use on MagTag. """ + import time + import board import displayio + import adafruit_imageload # use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.) diff --git a/examples/imageload_netpbm.py b/examples/imageload_netpbm.py index b896e6e..06ca3f1 100644 --- a/examples/imageload_netpbm.py +++ b/examples/imageload_netpbm.py @@ -12,9 +12,10 @@ """ +import adafruit_ili9341 import board import displayio -import adafruit_ili9341 + import adafruit_imageload spi = board.SPI() @@ -36,9 +37,7 @@ # image = "images/netpbm_p5_binary.pgm" image = "images/netpbm_p6_binary.ppm" -bitmap, palette = adafruit_imageload.load( - image, bitmap=displayio.Bitmap, palette=displayio.Palette -) +bitmap, palette = adafruit_imageload.load(image, bitmap=displayio.Bitmap, palette=displayio.Palette) bg_sprite = displayio.TileGrid(bitmap, pixel_shader=palette, x=0, y=0) diff --git a/examples/imageload_png_simpletest.py b/examples/imageload_png_simpletest.py index 07484e7..106ea69 100644 --- a/examples/imageload_png_simpletest.py +++ b/examples/imageload_png_simpletest.py @@ -4,13 +4,17 @@ import board import displayio from vectorio import Rectangle + import adafruit_imageload # built-in display display = board.DISPLAY -# load png image +# load png image. Uncomment to try other supported formats. image, palette = adafruit_imageload.load("images/test_image.png") +# image, palette = adafruit_imageload.load("images/test_image_grayscale.png") +# image, palette = adafruit_imageload.load("images/test_image_rgb.png") +# image, palette = adafruit_imageload.load("images/test_image_2bit.png") # Set the transparency index color to be hidden palette.make_transparent(0) @@ -23,9 +27,7 @@ # make a blank background bg_palette = displayio.Palette(1) bg_palette[0] = 0xFFFFFF -rect = Rectangle( - pixel_shader=bg_palette, width=display.width, height=display.height, x=0, y=0 -) +rect = Rectangle(pixel_shader=bg_palette, width=display.width, height=display.height, x=0, y=0) # make a group to show on the display group = displayio.Group() diff --git a/examples/imageload_simpletest.py b/examples/imageload_simpletest.py index fbfc52d..1481791 100644 --- a/examples/imageload_simpletest.py +++ b/examples/imageload_simpletest.py @@ -3,6 +3,7 @@ import board import displayio + import adafruit_imageload image, palette = adafruit_imageload.load("images/4bit.bmp") diff --git a/examples/imageload_tilegrid_inflator_simpletest.py b/examples/imageload_tilegrid_inflator_simpletest.py index 50463a0..867b6b5 100644 --- a/examples/imageload_tilegrid_inflator_simpletest.py +++ b/examples/imageload_tilegrid_inflator_simpletest.py @@ -3,6 +3,7 @@ import board import displayio + import adafruit_imageload from adafruit_imageload.tilegrid_inflator import inflate_tilegrid diff --git a/examples/images/test_image_2bit.png.license b/examples/images/test_image_2bit.png.license new file mode 100644 index 0000000..6a552de --- /dev/null +++ b/examples/images/test_image_2bit.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2024 Foamyguy +# SPDX-License-Identifier: MIT diff --git a/examples/images/test_image_grayscale.png.license b/examples/images/test_image_grayscale.png.license new file mode 100644 index 0000000..ad03cf2 --- /dev/null +++ b/examples/images/test_image_grayscale.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2022 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/examples/images/test_image_rgb.png.license b/examples/images/test_image_rgb.png.license new file mode 100644 index 0000000..ad03cf2 --- /dev/null +++ b/examples/images/test_image_rgb.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2022 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..db37c83 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,99 @@ +# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +target-version = "py38" +line-length = 100 + +[lint] +select = ["I", "PL", "UP"] + +extend-select = [ + "D419", # empty-docstring + "E501", # line-too-long + "W291", # trailing-whitespace + "PLC0414", # useless-import-alias + "PLC2401", # non-ascii-name + "PLC2801", # unnecessary-dunder-call + "PLC3002", # unnecessary-direct-lambda-call + "E999", # syntax-error + "PLE0101", # return-in-init + "F706", # return-outside-function + "F704", # yield-outside-function + "PLE0116", # continue-in-finally + "PLE0117", # nonlocal-without-binding + "PLE0241", # duplicate-bases + "PLE0302", # unexpected-special-method-signature + "PLE0604", # invalid-all-object + "PLE0605", # invalid-all-format + "PLE0643", # potential-index-error + "PLE0704", # misplaced-bare-raise + "PLE1141", # dict-iter-missing-items + "PLE1142", # await-outside-async + "PLE1205", # logging-too-many-args + "PLE1206", # logging-too-few-args + "PLE1307", # bad-string-format-type + "PLE1310", # bad-str-strip-call + "PLE1507", # invalid-envvar-value + "PLE2502", # bidirectional-unicode + "PLE2510", # invalid-character-backspace + "PLE2512", # invalid-character-sub + "PLE2513", # invalid-character-esc + "PLE2514", # invalid-character-nul + "PLE2515", # invalid-character-zero-width-space + "PLR0124", # comparison-with-itself + "PLR0202", # no-classmethod-decorator + "PLR0203", # no-staticmethod-decorator + "UP004", # useless-object-inheritance + "PLR0206", # property-with-parameters + "PLR0904", # too-many-public-methods + "PLR0911", # too-many-return-statements + "PLR0912", # too-many-branches + "PLR0913", # too-many-arguments + "PLR0914", # too-many-locals + "PLR0915", # too-many-statements + "PLR0916", # too-many-boolean-expressions + "PLR1702", # too-many-nested-blocks + "PLR1704", # redefined-argument-from-local + "PLR1711", # useless-return + "C416", # unnecessary-comprehension + "PLR1733", # unnecessary-dict-index-lookup + "PLR1736", # unnecessary-list-index-lookup + + # ruff reports this rule is unstable + #"PLR6301", # no-self-use + + "PLW0108", # unnecessary-lambda + "PLW0120", # useless-else-on-loop + "PLW0127", # self-assigning-variable + "PLW0129", # assert-on-string-literal + "B033", # duplicate-value + "PLW0131", # named-expr-without-context + "PLW0245", # super-without-brackets + "PLW0406", # import-self + "PLW0602", # global-variable-not-assigned + "PLW0603", # global-statement + "PLW0604", # global-at-module-level + + # fails on the try: import typing used by libraries + #"F401", # unused-import + + "F841", # unused-variable + "E722", # bare-except + "PLW0711", # binary-op-exception + "PLW1501", # bad-open-mode + "PLW1508", # invalid-envvar-default + "PLW1509", # subprocess-popen-preexec-fn + "PLW2101", # useless-with-lock + "PLW3301", # nested-min-max +] + +ignore = [ + "PLR2004", # magic-value-comparison + "UP030", # format literals + "PLW1514", # unspecified-encoding + +] + +[format] +line-ending = "lf" diff --git a/tests/displayio_shared_bindings.py b/tests/displayio_shared_bindings.py index fcd96bc..5d796d7 100644 --- a/tests/displayio_shared_bindings.py +++ b/tests/displayio_shared_bindings.py @@ -34,6 +34,7 @@ * Author(s): Matt Land """ + from typing import Union @@ -76,9 +77,7 @@ def __setitem__(self, key: Union[tuple, int], value: int) -> None: if value > 255: raise ValueError(f"pixel value {value} too large") if self.data.get(key): - raise ValueError( - f"pixel {self._decode(key)}/{key} already set, cannot set again" - ) + raise ValueError(f"pixel {self._decode(key)}/{key} already set, cannot set again") self.data[key] = value def __getitem__(self, item: Union[tuple, int]) -> bytearray: @@ -89,9 +88,7 @@ def __getitem__(self, item: Union[tuple, int]) -> bytearray: try: return self.data[item] except KeyError as err: - raise RuntimeError( - "no data at {} [{}]".format(self._decode(item), item) - ) from err + raise RuntimeError(f"no data at {self._decode(item)} [{item}]") from err def validate(self, detect_empty_image=True) -> None: """ @@ -160,9 +157,7 @@ def __setitem__(self, key: int, value: Union[bytes, int, bytearray]) -> None: if isinstance(value, int) and value > 0xFFFFFF: raise ValueError(f"palette color int {value} is too large") if self.colors.get(key): - raise ValueError( - f"palette color {key} was already set, should not reassign" - ) + raise ValueError(f"palette color {key} was already set, should not reassign") self.colors[key] = value def __getitem__(self, item: int) -> Union[bytes, int, bytearray]: @@ -171,9 +166,7 @@ def __getitem__(self, item: int) -> Union[bytes, int, bytearray]: It is provided here for debugging purposes. """ if item >= self.num_colors: - raise ValueError( - f"palette index {item} should be less than {self.num_colors}" - ) + raise ValueError(f"palette index {item} should be less than {self.num_colors}") if not self.colors.get(item): raise ValueError(f"palette index {item} is not set") return self.colors[item] @@ -186,17 +179,14 @@ def validate(self): raise IndexError("no palette colors were set") if len(self.colors) != self.num_colors: raise IndexError( - "palette was initialized for {} colors, but only {} were inserted".format( - self.num_colors, len(self.colors) - ) + f"palette was initialized for {self.num_colors} " + f"colors, but only {len(self.colors)} were inserted" ) for i in range(self.num_colors): try: self.colors except IndexError as err: - raise ValueError( - "missing color `{}` in palette color list".format(i) - ) from err + raise ValueError(f"missing color `{i}` in palette color list") from err def __str__(self): """ diff --git a/tests/test_bitmap_c_interface.py b/tests/test_bitmap_c_interface.py index c9cb703..e4d8727 100644 --- a/tests/test_bitmap_c_interface.py +++ b/tests/test_bitmap_c_interface.py @@ -28,7 +28,9 @@ * Author(s): Matt Land """ + from unittest import TestCase + from .displayio_shared_bindings import Bitmap_C_Interface @@ -41,7 +43,7 @@ def test_init(self): def test_abs(self): b = Bitmap_C_Interface(5, 2, 1) - self.assertEqual(9, b._abs_pos(4, 1)) # pylint: disable=protected-access + self.assertEqual(9, b._abs_pos(4, 1)) def test_set_tuple(self): b = Bitmap_C_Interface(2, 4, 1) @@ -76,7 +78,7 @@ def test_max(self): def test_uninitialized(self): b = Bitmap_C_Interface(2, 4, 1) with self.assertRaises(RuntimeError): - b[1, 1] # pylint: disable=pointless-statement + b[1, 1] def test_validate_throws(self): b = Bitmap_C_Interface(2, 4, 1) @@ -95,6 +97,6 @@ def test_repr(self): def test_decode(self): b = Bitmap_C_Interface(4, 4, 1) - self.assertEqual((0, 0), b._decode(0)) # pylint: disable=protected-access - encoded = b._abs_pos(3, 3) # pylint: disable=protected-access - self.assertEqual((3, 3), b._decode(encoded)) # pylint: disable=protected-access + self.assertEqual((0, 0), b._decode(0)) + encoded = b._abs_pos(3, 3) + self.assertEqual((3, 3), b._decode(encoded)) diff --git a/tests/test_bmp_indexed_load.py b/tests/test_bmp_indexed_load.py index 5e72a38..b9c87f1 100644 --- a/tests/test_bmp_indexed_load.py +++ b/tests/test_bmp_indexed_load.py @@ -29,15 +29,15 @@ import os from unittest import TestCase + from adafruit_imageload import load + from .displayio_shared_bindings import Bitmap_C_Interface, Palette_C_Interface class TestBmpIndexedLoad(TestCase): def test_order_bgra_to_rgba(self): - test_file = os.path.join( - os.path.dirname(__file__), "..", "examples", "images", "4bit.bmp" - ) + test_file = os.path.join(os.path.dirname(__file__), "..", "examples", "images", "4bit.bmp") bitmap, palette = load( file_or_filename=test_file, diff --git a/tests/test_palette_c_interface.py b/tests/test_palette_c_interface.py index 457f468..e9c56c8 100644 --- a/tests/test_palette_c_interface.py +++ b/tests/test_palette_c_interface.py @@ -28,7 +28,9 @@ * Author(s): Matt Land """ + from unittest import TestCase + from .displayio_shared_bindings import Palette_C_Interface @@ -54,17 +56,17 @@ def test_get_int(self): @staticmethod def test_set_byte(): palette = Palette_C_Interface(1) - palette[0] = b"\xFF\xFF\xFF" + palette[0] = b"\xff\xff\xff" def test_get_byte(self): palette = Palette_C_Interface(1) - palette[0] = b"\xFF\xFF\xFF" - self.assertEqual(b"\xFF\xFF\xFF", palette[0]) + palette[0] = b"\xff\xff\xff" + self.assertEqual(b"\xff\xff\xff", palette[0]) @staticmethod def test_set_bytearray(): palette = Palette_C_Interface(1) - palette[0] = bytearray(b"\xFF\xFF\xFF") + palette[0] = bytearray(b"\xff\xff\xff") def test_prevents_out_of_range(self): palette = Palette_C_Interface(1) @@ -78,7 +80,7 @@ def test_prevents_out_of_range(self): def test_prevents_set_non_allowed(self): palette = Palette_C_Interface(1) try: - palette[0] = "\xFF\xFF\xFF" # attempt with a string, which is not allowed + palette[0] = "\xff\xff\xff" # attempt with a string, which is not allowed self.fail("exception should have thrown") except ValueError as err: if "should be" not in str(err): @@ -87,12 +89,12 @@ def test_prevents_set_non_allowed(self): @staticmethod def test_validate_success(): palette = Palette_C_Interface(1) - palette[0] = b"\xFF\xFF\xFF" + palette[0] = b"\xff\xff\xff" palette.validate() def test_validate_fails(self): palette = Palette_C_Interface(2) - palette[1] = b"\xFF\xFF\xFF" + palette[1] = b"\xff\xff\xff" try: palette.validate() self.fail("exception should have thrown") @@ -103,5 +105,5 @@ def test_validate_fails(self): @staticmethod def test_str(): palette = Palette_C_Interface(1) - palette[0] = b"\xFF\xFF\xFF" + palette[0] = b"\xff\xff\xff" print(str(palette)) diff --git a/tests/test_pbm_load.py b/tests/test_pbm_load.py index bc653eb..f1ba849 100644 --- a/tests/test_pbm_load.py +++ b/tests/test_pbm_load.py @@ -26,23 +26,24 @@ * Author(s): Matt Land """ + import os from io import BytesIO from unittest import TestCase + from adafruit_imageload import pnm from adafruit_imageload.pnm.pbm_binary import iterbits, reverse + from .displayio_shared_bindings import Bitmap_C_Interface, Palette_C_Interface class TestPbmLoad(TestCase): - def test_load_fails_with_no_header_data(self): # pylint: disable=invalid-name + def test_load_fails_with_no_header_data(self): file = BytesIO(b"some initial binary data: \x00\x01") try: - pnm.load( - file, b"P1", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface - ) + pnm.load(file, b"P1", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface) self.fail("should have failed") - except Exception as caught_exception: # pylint: disable=broad-except + except Exception as caught_exception: if "Unsupported image format" not in str(caught_exception): raise @@ -102,7 +103,7 @@ def test_load_works_p4_binary(self): self.assertEqual(15, bitmap.height) bitmap.validate() - def test_load_works_p4_binary_high_res(self): # pylint: disable=invalid-name + def test_load_works_p4_binary_high_res(self): test_file = os.path.join( os.path.dirname(__file__), "..", diff --git a/tests/test_pgm_load.py b/tests/test_pgm_load.py index dd1bc09..e5c0445 100644 --- a/tests/test_pgm_load.py +++ b/tests/test_pgm_load.py @@ -26,9 +26,12 @@ * Author(s): Matt Land """ + import os from unittest import TestCase + from adafruit_imageload import pnm + from .displayio_shared_bindings import Bitmap_C_Interface, Palette_C_Interface diff --git a/tests/test_ppm_load.py b/tests/test_ppm_load.py index bb8de7b..dfe081c 100644 --- a/tests/test_ppm_load.py +++ b/tests/test_ppm_load.py @@ -26,11 +26,14 @@ * Author(s): Matt Land """ + import os from io import BytesIO from unittest import TestCase + from adafruit_imageload import pnm from adafruit_imageload.pnm.ppm_ascii import read_three_colors + from .displayio_shared_bindings import Bitmap_C_Interface, Palette_C_Interface From c270013eeb3c5aada3c73ae0b475fc007c4c8ac9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 5 Aug 2024 09:08:33 -0500 Subject: [PATCH 070/111] noqa exclude for f-string repr usage --- adafruit_imageload/pnm/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/pnm/__init__.py b/adafruit_imageload/pnm/__init__.py index 7a18aeb..b178299 100644 --- a/adafruit_imageload/pnm/__init__.py +++ b/adafruit_imageload/pnm/__init__.py @@ -124,7 +124,8 @@ def load( # noqa: PLR0912 Too many branches next_byte = file.read(1) if next_byte == b"": - raise RuntimeError(f"Unsupported image format {magic_number!r}") + # mpy-cross does not support !r in f-string substitution, so ignore ruff rule + raise RuntimeError("Unsupported image format {!r}".format(magic_number)) # noqa: UP032, f-string if next_byte == b"#": # comment found, seek until a newline or EOF is found while file.read(1) not in [b"", b"\n"]: # EOF or NL pass From 56a964448b50c794bfeb1bbad5cc09510d175164 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sun, 11 Aug 2024 14:38:59 -0500 Subject: [PATCH 071/111] add image files --- examples/images/test_image_2bit.png | Bin 0 -> 624 bytes examples/images/test_image_grayscale.png | Bin 0 -> 10556 bytes examples/images/test_image_rgb.png | Bin 0 -> 7565 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/images/test_image_2bit.png create mode 100644 examples/images/test_image_grayscale.png create mode 100644 examples/images/test_image_rgb.png diff --git a/examples/images/test_image_2bit.png b/examples/images/test_image_2bit.png new file mode 100644 index 0000000000000000000000000000000000000000..6c7d8ca6d34bc28d78ad05ba1828bd52f6d050bf GIT binary patch literal 624 zcmV-$0+0QPP)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg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FU9y2Aeb@IN`nt^4(+UQ}GO* zyyDcm8^6sjTVRy}ld`)BLs?3;o&~Kh7fxsj+w~>zuWP%?iF~w;D0m@9$PMqXs1YJJ zI411ttdAM{`vr%_ynWJf$n3+`vbTqx`N4FCF4ES6TcefwZwUZpXo;*j>lyQZ0M#<7 A6#xJL literal 0 HcmV?d00001 diff --git a/examples/images/test_image_rgb.png b/examples/images/test_image_rgb.png new file mode 100644 index 0000000000000000000000000000000000000000..f6c209b4e4777f50dd0c3821959fa5766c7d27e2 GIT binary patch literal 7565 zcmV;89dhD{P)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=u}ut^ z)et9y7{V4pLh^DTlSjx(^74|&GUqXwftj2)d5{^%AxsEa$RruIBrL`lFb2oi#+zhY zwq)&6OX_ZQS9e!;*Yf_5kS$xXBvQb#>jkx9WcHZ~NZgEeX7bMO4%XaNWq^ ztpZ#m0_O1X=YUr&U2EdMQ4!uFAZ7}1hhL8TuPS9GW$G+cX9%~W2!LEZL06`Y)>I?W zeEXA@u5EZ9kiQ%lPDya)E+}5d+|Wv7YvNllMVq|?ud{vdg`K9JTK?Yw5b11p=ye3O z>uNtQS9#|k+GD}cg*+KE1Ga%AIT3AvQg=1Q?wazJY|~AG?A&Y{`Tq9-Ia6v%cE+!t z@derE2%aPfE!J*s{?1Bny!$d1uCJtVa3`rYfdU3$X9Tb4jdW(3XIn=8@%I5a6CKI! zzx!atZL5lv%9HeDbLuS~eCFG%z35_mp)me%IqTP7%;D5_4sPot;0zP;RuYgSbE1X5 z?-`Pv6=dfe+sN;J--f(9>8Pqw=5(yD{?tk5YyoE7W^>QizDzW2qRKX9kL~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#-0udA!0zP=uS zcp}a~e?JEg9-!^$Q93$0XlZGow}0>-Ow)RDq^)gd;+f8A3Hb|4-Dur9QvLpam?CRr8Ig@=00000NkvXXu0mjf%G0T8 literal 0 HcmV?d00001 From c10b95abd5820b7c031b35c3d905a1a7a3f2f96e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 12 Aug 2024 14:58:16 -0500 Subject: [PATCH 072/111] remove images --- examples/images/test_image_2bit.png | Bin 624 -> 0 bytes examples/images/test_image_grayscale.png | Bin 10556 -> 0 bytes examples/images/test_image_rgb.png | Bin 7565 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/images/test_image_2bit.png delete mode 100644 examples/images/test_image_grayscale.png delete mode 100644 examples/images/test_image_rgb.png diff --git a/examples/images/test_image_2bit.png b/examples/images/test_image_2bit.png deleted file mode 100644 index 6c7d8ca6d34bc28d78ad05ba1828bd52f6d050bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmV-$0+0QPP)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=$lhXt+iM7PLixGjada*0RR98 z$^?0idTpS-FEZ0pKg%SdpHVL#BkY{W=g^^`z#t-?;D-Z|!vk?3To?fl0EEq^+PJ25 zf!L4Mc(r4Gc^W7@E;&B$nf{t3zw&m&xJ&0W##bx9;m3F34N@U5swu2r-8;s)QI12u z4DGvTKKU(5;n&FCY@!X9Ub3sPi_|9(m{(d`4_C>zY#+v#T#AlmjU7{Go-mf>5N}$S zYDwG5xW$@C@jlBgDU+Fc(|pU{>XGZiwA*GL(AK9#85e32uV%o%JS;x@+hLe#@HjnQ z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I3sxDoDcnn|7$f^eIr4?sLs%~a4(b;MT5(}mOwOI|<27*m zEnA_Ou0ebu+kC8#|24KmOJKa*iR8TWCg`neR+eXq4VZqN?v8mg?mh?Y05dhF%05PL z9=E$)ie|Pc2g5amD;l_Zo|pLNJ{jgY53XaAN!!)dD=?Lh*6U3cHVqz@HLHS2dt=5^#^=2_#XiL7F_(04YR64&av3xq-puGFK38I-uNlUZ2$ zwnyPwM#WG$Rvgr?v@vQX;%cgP3&Soh&1Q{H`6fUjCEqj41k!(DYdePR?I*e)59B2x zjqw#<9dHMUJQDGF01qJ2729kntjor%HqIuOQ^mEc6__qR!7kEe`DAQh)vmreWZ?(? zTMHWPu?o%3c{p-6GJ6e%udTLPn;zK~xHR=t&}7Hv{9e_h$k);4cI!zyyX*(9fU_n@ z=EbfACS?zY#JZSMoV0>5N_D8xK6+fKWud4kudHo_(G`TfcHVvSR2N&%=FA7xX%gu>s(hmIwh+(_k zGH47#>FRusR^IZKX)}3lGby-}Rkf`%>EuUAUfXA5nyc+OZ6eZ!Y@K=Zp;@lQY0c7+ zf6*%3g-NnE^sD3zyeU|804~9Z9{t?^PnI4I`nqG29GO6 z;5irF;7&Y+yXFJp^S3_0J=Xh#`{JsDYL_OX+70oROfwwD#PCPTs$=D$M{$m4M9J!= z%jc&>S4>RFU9y2Aeb@IN`nt^4(+UQ}GO* zyyDcm8^6sjTVRy}ld`)BLs?3;o&~Kh7fxsj+w~>zuWP%?iF~w;D0m@9$PMqXs1YJJ zI411ttdAM{`vr%_ynWJf$n3+`vbTqx`N4FCF4ES6TcefwZwUZpXo;*j>lyQZ0M#<7 A6#xJL diff --git a/examples/images/test_image_rgb.png b/examples/images/test_image_rgb.png deleted file mode 100644 index f6c209b4e4777f50dd0c3821959fa5766c7d27e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7565 zcmV;89dhD{P)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$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_}u-Fx<6TL!^U zgc&u}6oiUhdxZ)o3a+X^&nVCsr_$8bS zOGC-d7~Ckb;ng9ew8fBDVCM`6|M>L})3A95zCU-2@z88>1gLicDL^1Q6bVqkES8Yc7XGx&g$awF=XCxiWl(;^rpph9iv+gJ^0DKlwJd+^B^(2p z@grYL#OW*{5GrAQ=mXfcg)SJRJCZz_-a+TkZsPfF06|pLck(d5HdP(n*FVS`Ti?Lt za*@xaS+;x?#l^+6w6;(`Zyo~!0~|eil#S2-iN=G?EM9UxG)x||z;K?`&K)}#7#JXv z$&k)u(9#()S$)d)IBn-$RMd4N9?}=9@vL8Lm-FToYq)b;FSFuBRM|m7w#xpyFJwhi z58)S%Wr7T>@pH$Wm-66)FT&w8X;~oZGHG8J;gOpzVA1A1c;4#75N#xDd?(q$CMOio z3u)4YA)?w5no>JSn`2zm7moYhZ0XuvqN1(_d=7{F{Jgq3ELyaX3)fssJQ3rWr=P*A zs?^rh5Gg4k7!2ZaxroJLq|<3`z4a5P9Fsz!!0HdIf#Fw3HIGc>7v7CgKO@nUsHk5* zq0xVofO1i#-V9S>tN3x@6Wl!i;YD2c^g+C~bC@+0CCrKnm~@ww0Q`fIPED9TB8qqVh_?c2BU z`j##1Z#syU&YXJ^a)zZX2P{9H#4)FLeSUOeDynze_8kki@7Ve8b7#-0udA!0zP=uS zcp}a~e?JEg9-!^$Q93$0XlZGow}0>-Ow)RDq^)gd;+f8A3Hb|4-Dur9QvLpam?CRr8Ig@=00000NkvXXu0mjf%G0T8 From 983ae118640e4aef62b4af18bd9793bb80330118 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 12 Aug 2024 14:59:10 -0500 Subject: [PATCH 073/111] add images back --- examples/images/test_image_2bit.png | Bin 0 -> 624 bytes examples/images/test_image_grayscale.png | Bin 0 -> 10556 bytes examples/images/test_image_rgb.png | Bin 0 -> 7565 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/images/test_image_2bit.png create mode 100644 examples/images/test_image_grayscale.png create mode 100644 examples/images/test_image_rgb.png diff --git a/examples/images/test_image_2bit.png b/examples/images/test_image_2bit.png new file mode 100644 index 0000000000000000000000000000000000000000..6c7d8ca6d34bc28d78ad05ba1828bd52f6d050bf GIT binary patch literal 624 zcmV-$0+0QPP)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=$lhXt+iM7PLixGjada*0RR98 z$^?0idTpS-FEZ0pKg%SdpHVL#BkY{W=g^^`z#t-?;D-Z|!vk?3To?fl0EEq^+PJ25 zf!L4Mc(r4Gc^W7@E;&B$nf{t3zw&m&xJ&0W##bx9;m3F34N@U5swu2r-8;s)QI12u z4DGvTKKU(5;n&FCY@!X9Ub3sPi_|9(m{(d`4_C>zY#+v#T#AlmjU7{Go-mf>5N}$S zYDwG5xW$@C@jlBgDU+Fc(|pU{>XGZiwA*GL(AK9#85e32uV%o%JS;x@+hLe#@HjnQ z$CaTF>*x^UIAl;!(%Z18^vd_FL}5l?LUnTt@D~;qP)+Q<&#uSnT0o7+H}sEihX@)P z;gI)IUe}lb02(mCz`z=1VDO*FsqtPf&Zsl(vgVC%Z@6iw08WmDVFN$-NHg6%%f;(e z?MXJx=DUhwN11MMMDkqBKM}K_3X_K&zFuGO6NWNmd4O^eUEpe0e|ul8_&wuw#@g@f15+H%#jlCJ`J}f6m!E90bvRpF3**yxsPz*@pw@|# zg*gI4^jAV-iC#FRF#kYm0RaG7x?zE6j4zH1^1^u&0<^)Kt?ghC0jmvmRJVXw1RCIc z2qqChINJzIJ4}Qx295>m>ac2sA*cZUI5HX(=I<8}j0n>P|HMU5?~ldGV9-w$vadGS z$-)|BKn%ix)RfeeAc}@zg!53a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h$k);4cI!zyyX*(9fU_n@ z=EbfACS?zY#JZSMoV0>5N_D8xK6+fKWud4kudHo_(G`TfcHVvSR2N&%=FA7xX%gu>s(hmIwh+(_k zGH47#>FRusR^IZKX)}3lGby-}Rkf`%>EuUAUfXA5nyc+OZ6eZ!Y@K=Zp;@lQY0c7+ zf6*%3g-NnE^sD3zyeU|804~9Z9{t?^PnI4I`nqG29GO6 z;5irF;7&Y+yXFJp^S3_0J=Xh#`{JsDYL_OX+70oROfwwD#PCPTs$=D$M{$m4M9J!= z%jc&>S4>RFU9y2Aeb@IN`nt^4(+UQ}GO* zyyDcm8^6sjTVRy}ld`)BLs?3;o&~Kh7fxsj+w~>zuWP%?iF~w;D0m@9$PMqXs1YJJ zI411ttdAM{`vr%_ynWJf$n3+`vbTqx`N4FCF4ES6TcefwZwUZpXo;*j>lyQZ0M#<7 A6#xJL literal 0 HcmV?d00001 diff --git a/examples/images/test_image_rgb.png b/examples/images/test_image_rgb.png new file mode 100644 index 0000000000000000000000000000000000000000..f6c209b4e4777f50dd0c3821959fa5766c7d27e2 GIT binary patch literal 7565 zcmV;89dhD{P)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=u}ut^ z)et9y7{V4pLh^DTlSjx(^74|&GUqXwftj2)d5{^%AxsEa$RruIBrL`lFb2oi#+zhY zwq)&6OX_ZQS9e!;*Yf_5kS$xXBvQb#>jkx9WcHZ~NZgEeX7bMO4%XaNWq^ ztpZ#m0_O1X=YUr&U2EdMQ4!uFAZ7}1hhL8TuPS9GW$G+cX9%~W2!LEZL06`Y)>I?W zeEXA@u5EZ9kiQ%lPDya)E+}5d+|Wv7YvNllMVq|?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zVA1A1c;4#75N#xDd?(q$CMOio z3u)4YA)?w5no>JSn`2zm7moYhZ0XuvqN1(_d=7{F{Jgq3ELyaX3)fssJQ3rWr=P*A zs?^rh5Gg4k7!2ZaxroJLq|<3`z4a5P9Fsz!!0HdIf#Fw3HIGc>7v7CgKO@nUsHk5* zq0xVofO1i#-V9S>tN3x@6Wl!i;YD2c^g+C~bC@+0CCrKnm~@ww0Q`fIPED9TB8qqVh_?c2BU z`j##1Z#syU&YXJ^a)zZX2P{9H#4)FLeSUOeDynze_8kki@7Ve8b7#-0udA!0zP=uS zcp}a~e?JEg9-!^$Q93$0XlZGow}0>-Ow)RDq^)gd;+f8A3Hb|4-Dur9QvLpam?CRr8Ig@=00000NkvXXu0mjf%G0T8 literal 0 HcmV?d00001 From 5e6fcd5a3aa38ef57d276f01abe321924e5dc95b Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 12 Aug 2024 15:29:07 -0500 Subject: [PATCH 074/111] remove images --- examples/images/test_image_2bit.png | Bin 624 -> 0 bytes examples/images/test_image_grayscale.png | Bin 10556 -> 0 bytes examples/images/test_image_rgb.png | Bin 7565 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/images/test_image_2bit.png delete mode 100644 examples/images/test_image_grayscale.png delete mode 100644 examples/images/test_image_rgb.png diff --git a/examples/images/test_image_2bit.png b/examples/images/test_image_2bit.png deleted file mode 100644 index 6c7d8ca6d34bc28d78ad05ba1828bd52f6d050bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmV-$0+0QPP)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=$lh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uWP%?iF~w;D0m@9$PMqXs1YJJ zI411ttdAM{`vr%_ynWJf$n3+`vbTqx`N4FCF4ES6TcefwZwUZpXo;*j>lyQZ0M#<7 A6#xJL diff --git a/examples/images/test_image_rgb.png b/examples/images/test_image_rgb.png deleted file mode 100644 index f6c209b4e4777f50dd0c3821959fa5766c7d27e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7565 zcmV;89dhD{P)>%Qhp*q<`MZ~FAp$HX1tY!*hJy!^hXVIM4Dv_vh$W3MK=50&#-rhDE$VJiTe@ zocD>NtSl+S=fvX%U6A;Z>$1yloJ$V-d1lneX6A{b#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q;L}GeX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ0lHTZO zu_GX|4P0DzGb9-y=u}ut^ z)et9y7{V4pLh^DTlSjx(^74|&GUqXwftj2)d5{^%AxsEa$RruIBrL`lFb2oi#+zhY zwq)&6OX_ZQS9e!;*Yf_5kS$xXBvQb#>jkx9WcHZ~NZgEeX7bMO4%XaNWq^ ztpZ#m0_O1X=YUr&U2EdMQ4!uFAZ7}1hhL8TuPS9GW$G+cX9%~W2!LEZL06`Y)>I?W zeEXA@u5EZ9kiQ%lPDya)E+}5d+|Wv7YvNllMVq|?ud{vdg`K9JTK?Yw5b11p=ye3O z>uNtQS9#|k+GD}cg*+KE1Ga%AIT3AvQg=1Q?wazJY|~AG?A&Y{`Tq9-Ia6v%cE+!t z@derE2%aPfE!J*s{?1Bny!$d1uCJtVa3`rYfdU3$X9Tb4jdW(3XIn=8@%I5a6CKI! zzx!atZL5lv%9HeDbLuS~eCFG%z35_mp)me%IqTP7%;D5_4sPot;0zP;RuYgSbE1X5 z?-`Pv6=dfe+sN;J--f(9>8Pqw=5(yD{?tk5YyoE7W^>QizDzW2qRKX9kL~Ba#bsO` z$@0Bx9>Fh$N9${rMq6SZQN4>~K1#|QLbtM5SXTi_OV{2!mjRK_Qa|f!)wy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ur9QvLpam?CRr8Ig@=00000NkvXXu0mjf%G0T8 From 5801433e6ba64886e6a376e81322047f22b45dc7 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 12 Aug 2024 15:29:29 -0500 Subject: [PATCH 075/111] remove gitattr --- .gitattributes | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index d54c593..0000000 --- a/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries -# -# SPDX-License-Identifier: Unlicense - -* text eol=lf From f5fb63da6a616a3ebd31428b515459dd871aac68 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 12 Aug 2024 15:33:38 -0500 Subject: [PATCH 076/111] add images --- examples/images/test_image_2bit.png | Bin 0 -> 625 bytes examples/images/test_image_grayscale.png | Bin 0 -> 10557 bytes examples/images/test_image_rgb.png | Bin 0 -> 7566 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/images/test_image_2bit.png create mode 100644 examples/images/test_image_grayscale.png create mode 100644 examples/images/test_image_rgb.png diff --git a/examples/images/test_image_2bit.png b/examples/images/test_image_2bit.png new file mode 100644 index 0000000000000000000000000000000000000000..9cc741621c8bd913c54d1e28ba4d5553a85caabd GIT binary patch literal 625 zcmV-%0*?KOP)EX>4Tx04R}tkv&MmKpe$iTct%R73?75kfA!+MMcD^R-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)8atOf`EFfT~$W zCY2O&`BfqKiVy;bU;wicGxa%9Ov7`0-NVP%yExDCKKJM7R|+Nrd;)QT>4rtTK|H-_ z>74h8qpU0`#OK8023?T&k?XR{Z=6dG`*~*6$Y$n=qr^g~i{&n6WkV&NB91AlM*04n z%L?Z$&T6&J+V|uy3>UPOWvZqU!3vpUCQcPrMKk4BgcKjl_WO7x& z$gzMLR7j2={11M2Y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OWsCH?R+-``oVxHkNCPX|^Q5`D}JBo8UBSum; zTRuN6wqjyN>XHi@>ASxF(9d810O3LoW4`nIac@?z2TsWaAV&9h_u&(VUFZ$6gvfzb0J~yJnvPPKH z;FPehvp!}V;2#ne^Y%%{A&W12%ibPp<_Gf``Y1b39*tJ&za=!LhE~X$vtBX(2kxY) AA^-pY literal 0 HcmV?d00001 diff --git a/examples/images/test_image_rgb.png b/examples/images/test_image_rgb.png new file mode 100644 index 0000000000000000000000000000000000000000..975fe89cd7e77eeb8826bccc3eeebc9c5b8159c7 GIT binary patch literal 7566 zcmV;99dY7`P)EX>4Tx04R}tkv&MmKpe$iTct%R73?75kfA!+MMcD^R-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)8atOf`EFfT~$W zCY2O&`BfqKiVy;bU;wicGxa%9Ov7`0-NVP%yExDCKKJM7R|+Nrd;)QT>4rtTK|H-_ z>74h8qpU0`#OK8023?T&k?XR{Z=6dG`*~*6$Y$n=qr^g~i{&n6WkV&NB91AlM*04n z%L?Z$&T6&J+V|uy3>UPOWvZqU!3vpUCQcPrMKk4BgcKjl_WO7x& z$gzMLR7j2={11M2YZfOb+@x?4=zX#6k5M4F3$z-x{e5iPtrH;d3|wg)f2|43e3IVi zXt5(8vJG5ZcQknqxZDATo^;8O94SE4Un~OeXY@^ZVDJ{`TXTDB@8k3V$WmA78{ps& z7%Nfsy2rai-M#&LrrqBUmo0L&vX#|N00006VoOIv0GR-*0K{x@N;Uuh010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=m-N38zhQvzZL)h02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{02^jWL_t(|+U=crbR5;4??1J4cXfBESGD%Vn{3H8-my&# znAH#`gc!mWLPGL#Ad^SPO7ilO$uj3LnSq&{H+hg5$RSJ!S;!2yorV z;jIE(Bm(B}@#lb7EnREkzflq1BOqo9aED)x{I4oyCS~d@RA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 2024 09:24:05 -0500 Subject: [PATCH 077/111] remove deprecated get_html_theme_path() call Signed-off-by: foamyguy --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 7e8361c..15c9fc0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -100,7 +100,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From f33b92a9612a7ccbeaec72b43eecc24bf1cb51c3 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 7 Oct 2024 19:30:54 -0400 Subject: [PATCH 078/111] fix PNG images wider than 128 bits --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 84867b9..a78936c 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -110,7 +110,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - if depth < 8: + if depth < 8 or width > 128: # Work around the bug in displayio.Bitmap # https://github.com/adafruit/circuitpython/issues/6675 pixels_per_byte = 8 // depth From 3938d4ca91679eb3f5bd427fef5fba9314566785 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Wed, 9 Oct 2024 22:17:01 -0400 Subject: [PATCH 079/111] apply #74 workaround to all 8 bit mode 3 images --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index a78936c..d110938 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -110,7 +110,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - if depth < 8 or width > 128: + if depth <= 8: # Work around the bug in displayio.Bitmap # https://github.com/adafruit/circuitpython/issues/6675 pixels_per_byte = 8 // depth From 204d8b09759059ff5a8bac65f85e5747f739a8fd Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 01:16:27 -0400 Subject: [PATCH 080/111] Use memoryview for bitmap widths that it works for --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index d110938..e911287 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -110,7 +110,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - if depth <= 8: + if depth < 8 or (depth == 8 and width % 4 != 0): # Work around the bug in displayio.Bitmap # https://github.com/adafruit/circuitpython/issues/6675 pixels_per_byte = 8 // depth From 949ff2dbc081aab509f6137e6ab7925ae939642c Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 01:44:46 -0400 Subject: [PATCH 081/111] remove portion of workaround for resolved bug --- adafruit_imageload/png.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index e911287..1c5f323 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -110,9 +110,11 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - if depth < 8 or (depth == 8 and width % 4 != 0): - # Work around the bug in displayio.Bitmap + if width % 4 != 0: + # Work around the bugs in displayio.Bitmap + # The first should have been resolved by #9479 # https://github.com/adafruit/circuitpython/issues/6675 + # https://github.com/adafruit/circuitpython/issues/9707 pixels_per_byte = 8 // depth for x in range(0, width, pixels_per_byte): byte = data_bytes[src] From 77136895d68d0cac7f97550c0a93d18824b3e50a Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 02:40:05 -0400 Subject: [PATCH 082/111] workaround still needed for all 4 bit or less images --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 1c5f323..68a8d8e 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -110,7 +110,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for y in range(height): dst = y * scanline src = y * (scanline + 1) + 1 - if width % 4 != 0: + if depth < 5 or width % 4 != 0: # Work around the bugs in displayio.Bitmap # The first should have been resolved by #9479 # https://github.com/adafruit/circuitpython/issues/6675 From 42cfb2b693d7951216914628706a36a295e4902e Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 03:15:28 -0400 Subject: [PATCH 083/111] Identified issue with memoryview copy, only 4bit and less need workaround now --- adafruit_imageload/png.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 68a8d8e..094b962 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -108,9 +108,11 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements bmp = bitmap(width, height, colors) mem = memoryview(bmp) for y in range(height): - dst = y * scanline + # Adjust for Displayio.Bitmap filler to scanline at byte boundry + filladj = (y * ((4 - (width % 4)) % 4)) + dst = y * scanline + filladj src = y * (scanline + 1) + 1 - if depth < 5 or width % 4 != 0: + if depth < 5: # Work around the bugs in displayio.Bitmap # The first should have been resolved by #9479 # https://github.com/adafruit/circuitpython/issues/6675 From dde5d395276ff935d7b65860bcb7ab4432024627 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 03:27:03 -0400 Subject: [PATCH 084/111] pre-commit formatting --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 094b962..d4e8c2d 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -109,7 +109,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements mem = memoryview(bmp) for y in range(height): # Adjust for Displayio.Bitmap filler to scanline at byte boundry - filladj = (y * ((4 - (width % 4)) % 4)) + filladj = y * ((4 - (width % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 if depth < 5: From 296bacd6771849dae5f6c428b72d0597f965fc40 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 03:58:40 -0400 Subject: [PATCH 085/111] Use work around for <8 depth for now --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index d4e8c2d..83e2d36 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -112,7 +112,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements filladj = y * ((4 - (width % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 - if depth < 5: + if depth < 8: # Work around the bugs in displayio.Bitmap # The first should have been resolved by #9479 # https://github.com/adafruit/circuitpython/issues/6675 From f931aeefe2fec715dc55e25d8f2afd60d611084f Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 04:00:11 -0400 Subject: [PATCH 086/111] comment fix --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 83e2d36..0156ee3 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -108,7 +108,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements bmp = bitmap(width, height, colors) mem = memoryview(bmp) for y in range(height): - # Adjust for Displayio.Bitmap filler to scanline at byte boundry + # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry filladj = y * ((4 - (width % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 From 9637b47b847e28436277733f336efd964dd3841b Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 04:20:07 -0400 Subject: [PATCH 087/111] finally, remove workaround code --- adafruit_imageload/png.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 0156ee3..b4d73cd 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -109,24 +109,10 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements mem = memoryview(bmp) for y in range(height): # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry - filladj = y * ((4 - (width % 4)) % 4) + filladj = y * ((4 - (scanline % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 - if depth < 8: - # Work around the bugs in displayio.Bitmap - # The first should have been resolved by #9479 - # https://github.com/adafruit/circuitpython/issues/6675 - # https://github.com/adafruit/circuitpython/issues/9707 - pixels_per_byte = 8 // depth - for x in range(0, width, pixels_per_byte): - byte = data_bytes[src] - for pixel in range(pixels_per_byte): - bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( - (1 << depth) - 1 - ) - src += 1 - else: - mem[dst : dst + scanline] = data_bytes[src : src + scanline] + mem[dst : dst + scanline] = data_bytes[src : src + scanline] return bmp, pal # RGB, RGBA or Grayscale import displayio From 82c08417986b0c20771a44399a5ad894020c1552 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 12:24:14 -0400 Subject: [PATCH 088/111] workaound left in as comments for documentation --- adafruit_imageload/png.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index b4d73cd..5cf9d54 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -112,6 +112,21 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements filladj = y * ((4 - (scanline % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 + # Work around the bug in displayio.Bitmap - removed afer resolution + # however left here as comments because it's helpful in + # understanding the memoryview scanline and adjustment calculations + # https://github.com/adafruit/circuitpython/issues/6675 + # https://github.com/adafruit/circuitpython/issues/9707 + # + # pixels_per_byte = 8 // depth + # for x in range(0, width, pixels_per_byte): + # byte = data_bytes[src] + # for pixel in range(pixels_per_byte): + # bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( + # (1 << depth) - 1 + # ) + # src += 1 + # mem[dst : dst + scanline] = data_bytes[src : src + scanline] return bmp, pal # RGB, RGBA or Grayscale From c23d7364eddb666b69193bd94c0993543aa1e5b5 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 22:25:23 -0400 Subject: [PATCH 089/111] Use workaround for older versions of CircuitPython --- adafruit_imageload/png.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 5cf9d54..8d36fbc 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -25,6 +25,7 @@ except ImportError: pass +from sys import implementation import struct import zlib @@ -112,22 +113,23 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements filladj = y * ((4 - (scanline % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 - # Work around the bug in displayio.Bitmap - removed afer resolution - # however left here as comments because it's helpful in - # understanding the memoryview scanline and adjustment calculations + # Work around the bug in displayio.Bitmap + # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 # https://github.com/adafruit/circuitpython/issues/9707 - # - # pixels_per_byte = 8 // depth - # for x in range(0, width, pixels_per_byte): - # byte = data_bytes[src] - # for pixel in range(pixels_per_byte): - # bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( - # (1 << depth) - 1 - # ) - # src += 1 - # - mem[dst : dst + scanline] = data_bytes[src : src + scanline] + if ((implementation[1][0] == 9 and implementation[1][1] < 2) or + implementation[1][0] < 9) and (depth < 8 or width % 4 != 0): + + pixels_per_byte = 8 // depth + for x in range(0, width, pixels_per_byte): + byte = data_bytes[src] + for pixel in range(pixels_per_byte): + bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( + (1 << depth) - 1 + ) + src += 1 + else: + mem[dst : dst + scanline] = data_bytes[src : src + scanline] return bmp, pal # RGB, RGBA or Grayscale import displayio From 20d7a15655eb4f563edda7c2e67e47680e60a6fb Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 22:28:43 -0400 Subject: [PATCH 090/111] pre-commit formatting --- adafruit_imageload/png.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 8d36fbc..1854e04 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -117,9 +117,9 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 # https://github.com/adafruit/circuitpython/issues/9707 - if ((implementation[1][0] == 9 and implementation[1][1] < 2) or - implementation[1][0] < 9) and (depth < 8 or width % 4 != 0): - + if ( + (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 + ) and (depth < 8 or width % 4 != 0): pixels_per_byte = 8 // depth for x in range(0, width, pixels_per_byte): byte = data_bytes[src] From 1b6ebf7e0928f3f0ec0fd2c2abc20646029adbf9 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Thu, 10 Oct 2024 22:32:59 -0400 Subject: [PATCH 091/111] move import for pre-commmit --- adafruit_imageload/png.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 1854e04..7374f92 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -25,9 +25,9 @@ except ImportError: pass -from sys import implementation import struct import zlib +from sys import implementation __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" @@ -113,13 +113,13 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements filladj = y * ((4 - (scanline % 4)) % 4) dst = y * scanline + filladj src = y * (scanline + 1) + 1 - # Work around the bug in displayio.Bitmap - # remove once CircuitPython 9.1 is no longer supported - # https://github.com/adafruit/circuitpython/issues/6675 - # https://github.com/adafruit/circuitpython/issues/9707 if ( (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 ) and (depth < 8 or width % 4 != 0): + # Work around the bug in displayio.Bitmap + # remove once CircuitPython 9.1 is no longer supported + # https://github.com/adafruit/circuitpython/issues/6675 + # https://github.com/adafruit/circuitpython/issues/9707 pixels_per_byte = 8 // depth for x in range(0, width, pixels_per_byte): byte = data_bytes[src] From 12f4cdccf9f13c9647e1e06acb77c55f95ebb132 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 11 Oct 2024 00:19:26 -0400 Subject: [PATCH 092/111] minor speed up when using workaround code --- adafruit_imageload/png.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 7374f92..6be3650 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -109,9 +109,6 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements bmp = bitmap(width, height, colors) mem = memoryview(bmp) for y in range(height): - # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry - filladj = y * ((4 - (scanline % 4)) % 4) - dst = y * scanline + filladj src = y * (scanline + 1) + 1 if ( (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 @@ -129,6 +126,9 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements ) src += 1 else: + # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry + filladj = y * ((4 - (scanline % 4)) % 4) + dst = y * scanline + filladj mem[dst : dst + scanline] = data_bytes[src : src + scanline] return bmp, pal # RGB, RGBA or Grayscale From 392007ca6b6921eb351a3e478d4dbe3b07dc01fa Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 11 Oct 2024 02:21:37 -0400 Subject: [PATCH 093/111] speed optimizations --- adafruit_imageload/png.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 6be3650..2c2f387 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -108,8 +108,13 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements if mode == 3: # indexed bmp = bitmap(width, height, colors) mem = memoryview(bmp) + pixels_per_byte = 8 // depth + # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry + filladj = (4 - (scanline % 4)) % 4 + dst = 0 + src = 1 + src_b = 1 for y in range(height): - src = y * (scanline + 1) + 1 if ( (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 ) and (depth < 8 or width % 4 != 0): @@ -117,19 +122,18 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 # https://github.com/adafruit/circuitpython/issues/9707 - pixels_per_byte = 8 // depth for x in range(0, width, pixels_per_byte): - byte = data_bytes[src] + byte = data_bytes[src_b] for pixel in range(pixels_per_byte): bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( (1 << depth) - 1 ) - src += 1 + src_b += 1 else: - # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry - filladj = y * ((4 - (scanline % 4)) % 4) - dst = y * scanline + filladj mem[dst : dst + scanline] = data_bytes[src : src + scanline] + dst += scanline + filladj + src += scanline + 1 + src_b = src return bmp, pal # RGB, RGBA or Grayscale import displayio From c491b815814c2885311150aff9edac0b564d20a5 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 11 Oct 2024 02:26:10 -0400 Subject: [PATCH 094/111] one more minor optimization --- adafruit_imageload/png.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 2c2f387..b31a88f 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -114,10 +114,15 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements dst = 0 src = 1 src_b = 1 + if ( + (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 + ) and (depth < 8 or width % 4 != 0): + workaround = True + else: + workaround = False + for y in range(height): - if ( - (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 - ) and (depth < 8 or width % 4 != 0): + if (workaround): # Work around the bug in displayio.Bitmap # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 From 3dbc21df315be6ceb7c15d3f3efe43dd945cce2f Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 11 Oct 2024 02:32:51 -0400 Subject: [PATCH 095/111] I even ran pre-commit this time.... --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index b31a88f..d4f9c70 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -122,7 +122,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements workaround = False for y in range(height): - if (workaround): + if workaround: # Work around the bug in displayio.Bitmap # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 From d22ccf5431ed29762347b77d6b29c7ab9589a0ee Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 14 Oct 2024 22:47:21 -0400 Subject: [PATCH 096/111] deshipus optimization --- adafruit_imageload/png.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index d4f9c70..0f85bd6 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -111,18 +111,12 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements pixels_per_byte = 8 // depth # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry filladj = (4 - (scanline % 4)) % 4 - dst = 0 src = 1 - src_b = 1 if ( (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 ) and (depth < 8 or width % 4 != 0): - workaround = True - else: - workaround = False - - for y in range(height): - if workaround: + src_b = 1 + for y in range(height): # Work around the bug in displayio.Bitmap # remove once CircuitPython 9.1 is no longer supported # https://github.com/adafruit/circuitpython/issues/6675 @@ -134,11 +128,14 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements (1 << depth) - 1 ) src_b += 1 - else: + src += scanline + 1 + src_b = src + else: + dst = 0 + for y in range(height): mem[dst : dst + scanline] = data_bytes[src : src + scanline] dst += scanline + filladj - src += scanline + 1 - src_b = src + src += scanline + 1 return bmp, pal # RGB, RGBA or Grayscale import displayio From 66fa04d45b0c3b2f7657d48bfbaef6a8ef006026 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 14 Oct 2024 22:54:12 -0400 Subject: [PATCH 097/111] Move workaround comment to top of workaround --- adafruit_imageload/png.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 0f85bd6..72a6e0a 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -115,12 +115,12 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements if ( (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 ) and (depth < 8 or width % 4 != 0): + # Work around the bug in displayio.Bitmap + # remove once CircuitPython 9.1 is no longer supported + # https://github.com/adafruit/circuitpython/issues/6675 + # https://github.com/adafruit/circuitpython/issues/9707 src_b = 1 for y in range(height): - # Work around the bug in displayio.Bitmap - # remove once CircuitPython 9.1 is no longer supported - # https://github.com/adafruit/circuitpython/issues/6675 - # https://github.com/adafruit/circuitpython/issues/9707 for x in range(0, width, pixels_per_byte): byte = data_bytes[src_b] for pixel in range(pixels_per_byte): From 872e1819bdd2cbb7d12f2ad0f388a2f4420eeda0 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Tue, 15 Oct 2024 01:46:18 -0400 Subject: [PATCH 098/111] Remove memoryview copy method --- adafruit_imageload/png.py | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 72a6e0a..31fda8a 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -104,38 +104,22 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements data_bytes = zlib.decompress(data) unit = (1, 0, 3, 1, 2, 0, 4)[mode] scanline = (width * depth * unit + 7) // 8 - colors = 1 << (depth * unit) if mode == 3: # indexed - bmp = bitmap(width, height, colors) - mem = memoryview(bmp) + bmp = bitmap(width, height, 1 << depth) pixels_per_byte = 8 // depth # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry filladj = (4 - (scanline % 4)) % 4 src = 1 - if ( - (implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9 - ) and (depth < 8 or width % 4 != 0): - # Work around the bug in displayio.Bitmap - # remove once CircuitPython 9.1 is no longer supported - # https://github.com/adafruit/circuitpython/issues/6675 - # https://github.com/adafruit/circuitpython/issues/9707 - src_b = 1 - for y in range(height): - for x in range(0, width, pixels_per_byte): - byte = data_bytes[src_b] - for pixel in range(pixels_per_byte): - bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & ( - (1 << depth) - 1 - ) - src_b += 1 - src += scanline + 1 - src_b = src - else: - dst = 0 - for y in range(height): - mem[dst : dst + scanline] = data_bytes[src : src + scanline] - dst += scanline + filladj - src += scanline + 1 + src_b = 1 + pixmask = (1 << depth) - 1 + for y in range(height): + for x in range(0, width, pixels_per_byte): + byte = data_bytes[src_b] + for pixel in range(pixels_per_byte): + bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & pixmask + src_b += 1 + src += scanline + 1 + src_b = src return bmp, pal # RGB, RGBA or Grayscale import displayio From 0132c78b7af36f20aad60b44b0c2925c9f7e6b83 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Tue, 15 Oct 2024 01:51:57 -0400 Subject: [PATCH 099/111] remove memoryview adjust variable --- adafruit_imageload/png.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 31fda8a..d08956e 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -107,8 +107,6 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements if mode == 3: # indexed bmp = bitmap(width, height, 1 << depth) pixels_per_byte = 8 // depth - # Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry - filladj = (4 - (scanline % 4)) % 4 src = 1 src_b = 1 pixmask = (1 << depth) - 1 From bd38609c670fe8aca5e8a7e009c6a79365c0beb6 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Tue, 15 Oct 2024 15:42:39 -0400 Subject: [PATCH 100/111] remove sys.implementation import --- adafruit_imageload/png.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index d08956e..89a9ded 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -27,7 +27,6 @@ import struct import zlib -from sys import implementation __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" From b164009110884c26a2e5792dccaff5347ce45554 Mon Sep 17 00:00:00 2001 From: Shawn McGee Date: Sun, 3 Nov 2024 21:16:23 -0700 Subject: [PATCH 101/111] Fixed truecolor bmp not using provided bitmap constructor --- adafruit_imageload/bmp/truecolor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/bmp/truecolor.py b/adafruit_imageload/bmp/truecolor.py index 1e6dccd..fe4baac 100755 --- a/adafruit_imageload/bmp/truecolor.py +++ b/adafruit_imageload/bmp/truecolor.py @@ -94,7 +94,7 @@ def load( # noqa: PLR0912, PLR0913, Too many branches, Too many arguments in fu # convert unsigned int to signed int when height is negative height = negative_height_check(height) - bitmap_obj = Bitmap(width, abs(height), 65535) + bitmap_obj = bitmap(width, abs(height), 65535) file.seek(data_start) line_size = width * (color_depth // 8) # Set the seek direction based on whether the height value is negative or positive From 7936be32bc5066307c1721b57d4ff8ce6f9b1ff4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 7 Nov 2024 16:43:40 -0600 Subject: [PATCH 102/111] show ColorConverter in type annotation --- adafruit_imageload/__init__.py | 4 ++-- adafruit_imageload/bmp/__init__.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_imageload/__init__.py b/adafruit_imageload/__init__.py index bf7d3e2..e149c41 100644 --- a/adafruit_imageload/__init__.py +++ b/adafruit_imageload/__init__.py @@ -24,7 +24,7 @@ Union, ) - from displayio import Bitmap, Palette + from displayio import Bitmap, ColorConverter, Palette from .displayio_types import BitmapConstructor, PaletteConstructor except ImportError: @@ -39,7 +39,7 @@ def load( *, bitmap: Optional[BitmapConstructor] = None, palette: Optional[PaletteConstructor] = None, -) -> Tuple[Bitmap, Optional[Palette]]: +) -> Tuple[Bitmap, Optional[Union[Palette, ColorConverter]]]: """Load pixel values (indices or colors) into a bitmap and colors into a palette. bitmap is the desired type. It must take width, height and color_depth in the constructor. It diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index d7b9801..715e98b 100755 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -15,9 +15,9 @@ try: from io import BufferedReader - from typing import List, Optional, Set, Tuple + from typing import List, Optional, Set, Tuple, Union - from displayio import Bitmap, Palette + from displayio import Bitmap, ColorConverter, Palette from ..displayio_types import BitmapConstructor, PaletteConstructor except ImportError: @@ -32,7 +32,7 @@ def load( *, bitmap: Optional[BitmapConstructor] = None, palette: Optional[PaletteConstructor] = None, -) -> Tuple[Optional[Bitmap], Optional[Palette]]: +) -> Tuple[Optional[Bitmap], Optional[Union[Palette, ColorConverter]]]: """Loads a bmp image from the open ``file``. Returns tuple of bitmap object and palette object. From 04bdc7d5103232cacc9ff7ec8b79d3094a371f12 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 7 Nov 2024 16:48:33 -0600 Subject: [PATCH 103/111] show ColorConverter in docstring --- adafruit_imageload/bmp/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/bmp/__init__.py b/adafruit_imageload/bmp/__init__.py index 715e98b..5c9c1df 100755 --- a/adafruit_imageload/bmp/__init__.py +++ b/adafruit_imageload/bmp/__init__.py @@ -35,7 +35,8 @@ def load( ) -> Tuple[Optional[Bitmap], Optional[Union[Palette, ColorConverter]]]: """Loads a bmp image from the open ``file``. - Returns tuple of bitmap object and palette object. + Returns tuple of `displayio.Bitmap` object and + `displayio.Palette` object, or `displayio.ColorConverter` object. :param io.BufferedReader file: Open file handle or compatible (like `io.BytesIO`) with the data of a BMP file. From 519d5f7af9dfdfe9444f2b358703dbdbc1243f78 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 16:25:25 -0600 Subject: [PATCH 104/111] move prev,line swap to after putting data into bitmap --- adafruit_imageload/png.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 89a9ded..010dff3 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -168,7 +168,6 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements src += 1 else: raise ValueError("Wrong filter.") - prev, line = line, prev if mode in (0, 4): # grayscale for x in range(width): c = line[x * unit] @@ -180,5 +179,8 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements ) else: raise ValueError("Unsupported color mode.") + + prev, line = line, prev + pal = displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565) return bmp, pal From 3bf2a56c6c281dffa6f2590d6d0b9d6d6f45d355 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 105/111] add sphinx configuration to rtd.yaml Signed-off-by: foamyguy --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: From bf6f32d392573ed33ecc43e8f62a289f3ceca758 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 17 Jan 2025 10:20:08 -0600 Subject: [PATCH 106/111] load png test case --- tests/test_png.png | Bin 0 -> 571 bytes tests/test_png.png.license | 2 ++ tests/test_png_load.py | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/test_png.png create mode 100644 tests/test_png.png.license create mode 100644 tests/test_png_load.py diff --git a/tests/test_png.png b/tests/test_png.png new file mode 100644 index 0000000000000000000000000000000000000000..314173af2fe07661454dcf2fc3fda8366117de38 GIT binary patch literal 571 zcmV-B0>u4^P)EX>4Tx04R}tkv&MmP!xqvTcsi`B6d)52w0u$q9Ts93Pq?8YK2xEOkVm2O&XFE z7e~Rh;NZ_<)xpJCR|i)?5c~mg7n~Gbq{RD@LW>wLJl@B7_Z;545AZiCOf|dWfT~$W zI++l%xm6+f3Lp9r#t=p&X6kdIn1W}0-BUN!U5saW_x)L6C2umoClJS(Zdk+{#50?g z&Uv3W!b*}td`>)J&;^Mfxh}i>#<}RQpJzslOnRO;LM#+JSngm}GF0Me;;5o(l<&{F ztZ?4qtX68Qbx;1nP+nVE<~pqrB(aDkh!7y7hB7L!5Tjiq#YCFU6CVCy$1jpgCRZ7Z z91EyIh2;3b|KRs*&BD~An-od_-7mKNF$M&8fo9#dzmILZc>)BUfh(=;uQq_$Ptxmc zEqVm>Z37qAZB5<-E_Z;zCtWfmM+(sL7Ye}p8GTa@7`O#`*W9_a&T;wxWN22Y8{ps& z7%x)xy2rbFI_LIpPiuZZgLQJP;t&>p00009P)t-s00960000300A{uIP5=M^32;bR za{vG?BLDy{BLR4&KXw2B00(qQO+^Rk0TB=cG;ySBVE_OC8FWQhbVF}#ZDnqB07G(R zVRU6=Aa`kWXdp*PO;A^X4i^9b01!z;K~xCWV^Cr6WSGRD0ssU{0VHZfD^vgg002ov JPDHLkV1lOI;%5K= literal 0 HcmV?d00001 diff --git a/tests/test_png.png.license b/tests/test_png.png.license new file mode 100644 index 0000000..beff0b4 --- /dev/null +++ b/tests/test_png.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/tests/test_png_load.py b/tests/test_png_load.py new file mode 100644 index 0000000..78e0a1c --- /dev/null +++ b/tests/test_png_load.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries +# SPDX-License-Identifier: MIT + +from unittest import TestCase + +from adafruit_imageload import load + + +class TestPngLoad(TestCase): + def test_expected_pixels(self): + img, palette = load("tests/test_png.png") + self.assertEqual(len(palette), 3) + self.assertEqual(img.width, 4) + self.assertEqual(img.height, 4) + + self.assertEqual(img[0, 0], 0) + self.assertEqual(img[1, 0], 2) + self.assertEqual(img[2, 0], 1) + self.assertEqual(img[3, 0], 0) + + self.assertEqual(img[0, 3], 0) + self.assertEqual(img[1, 3], 2) + self.assertEqual(img[2, 3], 1) + self.assertEqual(img[3, 3], 0) From 92f5030b799f6020fedee4405064884b3fd1051d Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 17 Feb 2025 10:48:18 -0600 Subject: [PATCH 107/111] dont try to set pixels outside of bounds --- adafruit_imageload/png.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 010dff3..0c5892f 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -113,7 +113,10 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements for x in range(0, width, pixels_per_byte): byte = data_bytes[src_b] for pixel in range(pixels_per_byte): - bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & pixmask + if x + pixel < width: + bmp[x + pixel, y] = ( + byte >> ((pixels_per_byte - pixel - 1) * depth) + ) & pixmask src_b += 1 src += scanline + 1 src_b = src From 4223574348fbe7abb6904982a435657f6760f8e4 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 21 Feb 2025 16:05:17 +0100 Subject: [PATCH 108/111] implement line filters for indexed PNG --- adafruit_imageload/png.py | 44 +++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) mode change 100644 => 100755 adafruit_imageload/png.py diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py old mode 100644 new mode 100755 index 0c5892f..b00ee9d --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -28,7 +28,7 @@ import struct import zlib -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git" @@ -106,12 +106,48 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements if mode == 3: # indexed bmp = bitmap(width, height, 1 << depth) pixels_per_byte = 8 // depth - src = 1 - src_b = 1 + src = 0 pixmask = (1 << depth) - 1 + line = bytearray(scanline) + prev = bytearray(scanline) for y in range(height): + filter_ = data_bytes[src] + src_b = src + 1 for x in range(0, width, pixels_per_byte): + # relative position on the line + pos = x // pixels_per_byte byte = data_bytes[src_b] + if filter_ == 0: + pass + elif filter_ == 1: # sub + prev_b = line[pos - unit] if pos >= unit else 0 + byte = (byte + prev_b) & 0xFF + elif filter_ == 2: # up + byte = (byte + prev[pos]) & 0xFF + elif filter_ == 3: # average + prev_b = line[pos - unit] if pos >= unit else 0 + byte = (byte + (prev_b + prev[pos]) // 2) & 0xFF + elif filter_ == 4: # paeth + a = line[pos - unit] if pos >= unit else 0 + if y > 0: + b = prev[pos] + c = prev[pos - unit] if pos >= unit else 0 + else: + b = c = 0 + p = a + b - c + pa = abs(p - a) + pb = abs(p - b) + pc = abs(p - c) + if pa <= pb and pa <= pc: + p = a + elif pb <= pc: + p = b + else: + p = c + byte = (data_bytes[src] + p) & 0xFF + else: + raise ValueError("Wrong filter.") + line[pos] = byte for pixel in range(pixels_per_byte): if x + pixel < width: bmp[x + pixel, y] = ( @@ -119,7 +155,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements ) & pixmask src_b += 1 src += scanline + 1 - src_b = src + prev, line = line, prev return bmp, pal # RGB, RGBA or Grayscale import displayio From 790497ee21c1025499850a3507fa2c844689817f Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 21 Feb 2025 16:25:07 +0100 Subject: [PATCH 109/111] fix paeth --- adafruit_imageload/png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index b00ee9d..215e313 100755 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -144,7 +144,7 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements p = b else: p = c - byte = (data_bytes[src] + p) & 0xFF + byte = (byte + p) & 0xFF else: raise ValueError("Wrong filter.") line[pos] = byte From 961c433f85f4575c7bc109aedf9c13915bc67a50 Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 27 Feb 2025 15:41:14 -0800 Subject: [PATCH 110/111] Remove secrets usage --- examples/imageload_from_web.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/imageload_from_web.py b/examples/imageload_from_web.py index 9a873a8..79c78dd 100644 --- a/examples/imageload_from_web.py +++ b/examples/imageload_from_web.py @@ -5,34 +5,32 @@ adafruit_requests using BytesIO """ -import ssl from io import BytesIO +from os import getenv +import adafruit_connection_manager import adafruit_requests as requests import board import displayio -import socketpool import wifi import adafruit_imageload -# Get wifi details and more from a secrets.py file -try: - from secrets import secrets -except ImportError: - print("WiFi secrets are kept in secrets.py, please add them there!") - raise +# Get WiFi details, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") -wifi.radio.connect(secrets["ssid"], secrets["password"]) +wifi.radio.connect(ssid, password) print("My IP address is", wifi.radio.ipv4_address) -socket = socketpool.SocketPool(wifi.radio) -https = requests.Session(socket, ssl.create_default_context()) +pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio) +ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio) +https = requests.Session(pool, ssl_context) url = "https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_ImageLoad/main/examples/images/4bit.bmp" -print("Fetching text from %s" % url) +print(f"Fetching text from {url}") response = https.get(url) print("GET complete") From 23f7866f2e69fbf9af54a0b9094ee3db53611b38 Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Wed, 9 Apr 2025 22:22:41 +0200 Subject: [PATCH 111/111] fix padded pbm binary loading --- adafruit_imageload/pnm/pbm_binary.py | 6 +++-- examples/images/netpbm_p4_mono_width.pbm | 3 +++ .../images/netpbm_p4_mono_width.pbm.license | 2 ++ tests/test_pbm_load.py | 23 ++++++++++++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 examples/images/netpbm_p4_mono_width.pbm create mode 100644 examples/images/netpbm_p4_mono_width.pbm.license diff --git a/adafruit_imageload/pnm/pbm_binary.py b/adafruit_imageload/pnm/pbm_binary.py index cecdba5..53d92df 100644 --- a/adafruit_imageload/pnm/pbm_binary.py +++ b/adafruit_imageload/pnm/pbm_binary.py @@ -38,6 +38,7 @@ def load( """ Load a P4 'PBM' binary image into the Bitmap """ + padded_width = (width + 7) // 8 * 8 x = 0 y = 0 while True: @@ -45,9 +46,10 @@ def load( if not next_byte: break # out of bits for bit in iterbits(next_byte): - bitmap[x, y] = bit + if x < width: + bitmap[x, y] = bit x += 1 - if x > width - 1: + if x > padded_width - 1: y += 1 x = 0 if y > height - 1: diff --git a/examples/images/netpbm_p4_mono_width.pbm b/examples/images/netpbm_p4_mono_width.pbm new file mode 100644 index 0000000..ef6a9e6 --- /dev/null +++ b/examples/images/netpbm_p4_mono_width.pbm @@ -0,0 +1,3 @@ +P4 +14 20 +ÏÌ·´·´·´·´·´·´·´·´{x|øøg˜Cøø{x¼ôßìà \ No newline at end of file diff --git a/examples/images/netpbm_p4_mono_width.pbm.license b/examples/images/netpbm_p4_mono_width.pbm.license new file mode 100644 index 0000000..5e64ae4 --- /dev/null +++ b/examples/images/netpbm_p4_mono_width.pbm.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2025 Karolis Stasaitis +# SPDX-License-Identifier: MIT diff --git a/tests/test_pbm_load.py b/tests/test_pbm_load.py index f1ba849..e999657 100644 --- a/tests/test_pbm_load.py +++ b/tests/test_pbm_load.py @@ -72,7 +72,7 @@ def test_load_works_p1_ascii(self): palette.validate() def test_load_works_p4_in_mem(self): - file = BytesIO(b"P4\n4 2\n\x55") + file = BytesIO(b"P4\n4 2\n\x5f\x5f") bitmap, palette = pnm.load( file, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface ) @@ -103,6 +103,27 @@ def test_load_works_p4_binary(self): self.assertEqual(15, bitmap.height) bitmap.validate() + def test_load_works_p4_binary_padded_width(self): + test_file = os.path.join( + os.path.dirname(__file__), + "..", + "examples", + "images", + "netpbm_p4_mono_width.pbm", + ) + with open(test_file, "rb") as file: + bitmap, palette = pnm.load( + file, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface + ) + self.assertEqual(1, palette.num_colors) + palette.validate() + self.assertEqual(b"\xff\xff\xff", palette[0]) + self.assertTrue(isinstance(bitmap, Bitmap_C_Interface)) + self.assertEqual(1, bitmap.colors) + self.assertEqual(14, bitmap.width) + self.assertEqual(20, bitmap.height) + bitmap.validate() + def test_load_works_p4_binary_high_res(self): test_file = os.path.join( os.path.dirname(__file__),