adafruit_imageload
¶
Load pixel values (indices or colors) into a bitmap and colors into a palette.
Author(s): Scott Shawcroft, Matt Land
- adafruit_imageload.load(file_or_filename: Union[str, BufferedReader], *, bitmap: Optional[Callable[[int, int, int], displayio.Bitmap]] = None, palette: Optional[Callable[[int], displayio.Palette]] = None) Tuple[displayio.Bitmap, Optional[displayio.Palette]] ¶
Load pixel values (indices or colors) into a bitmap and colors into a palette.
bitmap is the desired type. It must take width, height and color_depth in the constructor. It must also have a _load_row method to load a row’s worth of pixel data.
palette is the desired palette type. The constructor should take the number of colors and support assignment to indices via [].
adafruit_imageload.bmp
¶
Load pixel values (indices or colors) into a bitmap and colors into a palette from a BMP file.
Author(s): Scott Shawcroft, Matt Land
- adafruit_imageload.bmp.load(file: BufferedReader, *, bitmap: Optional[Callable[[int, int, int], displayio.Bitmap]] = None, palette: Optional[Callable[[int], displayio.Palette]] = None) Tuple[displayio.Bitmap, Optional[displayio.Palette]] ¶
Loads a bmp image from the open
file
.Returns tuple of bitmap object and palette object.
- Parameters
bitmap (object) – Type to store bitmap data. Must have API similar to
displayio.Bitmap
. Will be skipped if Nonepalette (object) – Type to store the palette. Must have API similar to
displayio.Palette
. Will be skipped if None
adafruit_imageload.bmp.indexed
¶
Load pixel values (indices or colors) into a bitmap and colors into a palette from an indexed BMP.
Author(s): Scott Shawcroft, Matt Land
- adafruit_imageload.bmp.indexed.decode_rle(bitmap: displayio.Bitmap, file: BufferedReader, compression: int, y_range: Tuple[int, int, int], width: int) None ¶
Helper to decode RLE images
- adafruit_imageload.bmp.indexed.load(file: BufferedReader, width: int, height: int, data_start: int, colors: int, color_depth: int, compression: int, *, bitmap: Optional[Callable[[int, int, int], displayio.Bitmap]] = None, palette: Optional[Callable[[int], displayio.Palette]] = None) Tuple[displayio.Bitmap, Optional[displayio.Palette]] ¶
Loads indexed bitmap data into bitmap and palette objects.
- Parameters
file (file) – The open bmp file
width (int) – Image width in pixels
height (int) – Image height in pixels
data_start (int) – Byte location where the data starts (after headers)
colors (int) – Number of distinct colors in the image
color_depth (int) – Number of bits used to store a value
compression (int) – 0 - none, 1 - 8bit RLE, 2 - 4bit RLE
adafruit_imageload.tilegrid_inflator
¶
Use a 3x3 spritesheet to inflate a larger grid of tiles, duplicating the center rows and columns as many times as needed to reach a target size.
Author(s): Tim Cocks, Matt Land
- adafruit_imageload.tilegrid_inflator.inflate_tilegrid(bmp_path: Optional[str] = None, target_size: Tuple[int, int] = (3, 3), tile_size: Optional[List[int]] = None, transparent_index: Optional[Union[tuple, int]] = None, bmp_obj: Optional[displayio.OnDiskBitmap] = None, bmp_palette: Optional[displayio.Palette] = None) displayio.TileGrid ¶
inflate a TileGrid of
target_size
in tiles from a 3x3 spritesheet by duplicating the center rows and columns.- Parameters
bmp_path (Optional[str]) – filepath to the 3x3 spritesheet bitmap file
target_size (Optional[tuple]) – desired size in tiles (target_width, target_height)
tile_size (Optional[tuple]) – size of the tiles in the 3x3 spritesheet. If None is used it will equally divide the width and height of the Bitmap by 3.
transparent_index (Optional[Union[tuple, int]]) – a single index within the palette to make transparent, or a tuple of multiple indexes to make transparent
bmp_obj (Optional[OnDiskBitmap]) – Already loaded 3x3 spritesheet in an OnDiskBitmap
bmp_palette (Optional[Palette]) – Already loaded spritesheet Palette