From d2c3d321d561fd5922f23bc5953766e2d78ff742 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 5 May 2023 15:55:30 +0200 Subject: [PATCH] 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: