refactor logic from review
This commit is contained in:
parent
a8f57a3c98
commit
609f6066c7
1 changed files with 3 additions and 4 deletions
|
|
@ -78,12 +78,11 @@ class GraphicsBase:
|
||||||
if not file_or_color:
|
if not file_or_color:
|
||||||
return # we're done, no background desired
|
return # we're done, no background desired
|
||||||
if isinstance(file_or_color, str): # it's a filename:
|
if isinstance(file_or_color, str): # it's a filename:
|
||||||
if file_or_color.lower().endswith(".bmp"):
|
file_lower = file_or_color.lower()
|
||||||
|
if file_lower.endswith(".bmp"):
|
||||||
background = displayio.OnDiskBitmap(file_or_color)
|
background = displayio.OnDiskBitmap(file_or_color)
|
||||||
palette = background.pixel_shader
|
palette = background.pixel_shader
|
||||||
elif file_or_color.lower().endswith(".jpg") or file_or_color.lower().endswith(".jpeg"):
|
elif file_lower.endswith(".jpg") or file_lower.endswith(".jpeg") or file_lower.endswith(".png"):
|
||||||
background, palette = adafruit_imageload.load(file_or_color)
|
|
||||||
elif file_or_color.lower().endswith(".png"):
|
|
||||||
background, palette = adafruit_imageload.load(file_or_color)
|
background, palette = adafruit_imageload.load(file_or_color)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Image File type {file_or_color} not supported")
|
raise ValueError(f"Image File type {file_or_color} not supported")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue