adafruit_imageload

Load pixel values (indices or colors) into a bitmap and colors into a palette.

  • Author(s): Scott Shawcroft

adafruit_imageload.load(file_or_filename, *, bitmap=None, palette=None)

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 pallete 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

adafruit_imageload.bmp.load(file, *, bitmap=None, palette=None)

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 None

  • palette (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

adafruit_imageload.bmp.indexed.decode_rle(bitmap, file, compression, y_range, width)

Helper to decode RLE images

adafruit_imageload.bmp.indexed.load(file, width, height, data_start, colors, color_depth, compression, *, bitmap=None, palette=None)

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

adafruit_imageload.tilegrid_inflator.inflate_tilegrid(bmp_path=None, target_size=(3, 3), tile_size=None, transparent_index=None, bmp_obj=None, bmp_palette=None)

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