Skip to content

Add png and gif to docs, and note png format restriction #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: