Skip to content

Commit

Permalink
Merge pull request #67 from Neradoc/more-docs
Browse files Browse the repository at this point in the history
Add png and gif to docs, and note png format restriction
  • Loading branch information
tannewt committed May 5, 2023
2 parents 1ae6b2c + d2c3d32 commit 46158cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions adafruit_imageload/bmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions adafruit_imageload/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions adafruit_imageload/png.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

0 comments on commit 46158cf

Please sign in to comment.