class documentation

class Image:

Constructor: Image()

View In Hierarchy

Represents an image with RGB565 pixel data for MicroPython.

The raw pixel data is stored in self._raw and can be used by the Draw class.

Method __del__ Release the raw pixel data and size.
Method __init__ Initialize an empty image with a zero size.
Method from_byte_array Create an image from a raw byte array.
Method from_path Load a 16-bit BMP from disk into raw RGB565 data.
Method from_string Create a tiny monochrome-style RGB565 image from ASCII art.
Method get_pixel Get RGB565 pixel value at coordinates (x, y).
Instance Variable is_8bit Undocumented
Instance Variable size Undocumented
Method _load_bmp Read BMP header and pixel data into self._raw as little-endian RGB565 bytes.
Instance Variable _raw Undocumented
def __del__(self):

Release the raw pixel data and size.

def __init__(self):

Initialize an empty image with a zero size.

def from_byte_array(self, data, size, is_8bit: bool = True) -> bool:

Create an image from a raw byte array.

Parameters
dataPixel data as bytes, bytearray, or memoryview.
size:VectorThe image size (width, height).
is_8bit:boolWhether the data is 8-bit. Defaults to True.
Returns
boolTrue on success.
Raises
ValueErrorIf the data length does not match the expected size.
def from_path(self, path: str) -> bool:

Load a 16-bit BMP from disk into raw RGB565 data.

Parameters
path:strThe path to the BMP file.
Returns
boolTrue on success, False on failure.
def from_string(self, image_str: str):

Create a tiny monochrome-style RGB565 image from ASCII art.

Parameters
image_str:strThe ASCII art string with one row per line.
def get_pixel(self, x: int, y: int) -> int:

Get RGB565 pixel value at coordinates (x, y).

Parameters
x:intThe X coordinate.
y:intThe Y coordinate.
Returns
intThe RGB565 pixel value, or 0 if out of bounds.
is_8bit =

Undocumented

size =

Undocumented

def _load_bmp(self, path: str, storage=None):

Read BMP header and pixel data into self._raw as little-endian RGB565 bytes.

Parameters
path:strThe path to the BMP file.
storageStorage instance for file access. Defaults to None.
Raises
ValueErrorIf the file is not a valid BMP.
_raw =

Undocumented