Skip to content

Commit 83bb738

Browse files
committed
Only import displayio if needed
1 parent 1c27079 commit 83bb738

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_imageload/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@
2828
* Author(s): Scott Shawcroft
2929
3030
"""
31-
import displayio
32-
3331
# pylint: disable=import-outside-toplevel
3432

3533
__version__ = "0.0.0-auto.0"
3634
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git"
3735

3836

39-
def load(filename, *, bitmap=displayio.Bitmap, palette=displayio.Palette):
37+
def load(filename, *, bitmap=None, palette=None):
4038
"""Load pixel values (indices or colors) into a bitmap and colors into a palette.
4139
4240
bitmap is the desired type. It must take width, height and color_depth in the constructor. It
@@ -45,6 +43,14 @@ def load(filename, *, bitmap=displayio.Bitmap, palette=displayio.Palette):
4543
palette is the desired pallete type. The constructor should take the number of colors and
4644
support assignment to indices via [].
4745
"""
46+
if not bitmap or not palette:
47+
import displayio
48+
49+
if not bitmap:
50+
bitmap = displayio.Bitmap
51+
if not palette:
52+
palette = displayio.Palette
53+
4854
with open(filename, "rb") as file:
4955
header = file.read(3)
5056
file.seek(0)

0 commit comments

Comments
 (0)