class documentation

JPEG decoder for Picoware.

Method __del__ Clean up decoder resources.
Method __init__ Initialize the JPEG decoder with display and buffer settings.
Method draw Draw a JPEG file at position (x, y) on the display.
Method draw_buffer Draw a JPEG image from bytes data into a BytesIO buffer.
Method _cleanup Wait for the decoder core and reset the running flag.
Method _decode_split Decode a JPEG from a file, streaming buffers as needed.
Method _get_option Return the decoder option for the given scale factor.
Method _get_scale Return (scale, (auto_x, auto_y)) so the image fits the display.
Method _init_buffers Allocate the file buffer and split it into decode buffers.
Method _read_into_buf Read data from the file into a buffer.
Method _start_split Start decoding a JPEG from the given buffer.
Method _test_buffer Check which buffers cover the requested data range.
Instance Variable _buffer_num Undocumented
Instance Variable _buffer_size Undocumented
Instance Variable _buffers Undocumented
Instance Variable _buffers_len Undocumented
Instance Variable _buffers_pos Undocumented
Instance Variable _decoder_running Undocumented
Instance Variable _filebuffer Undocumented
Instance Variable _max_height Undocumented
Instance Variable _max_width Undocumented
def __del__(self):

Clean up decoder resources.

def __init__(self, screen_width: int = 320, screen_height: int = 320, buffer_size: int = 1024 * 8, buffer_num: int = 2):

Initialize the JPEG decoder with display and buffer settings.

Parameters
screen_width:intMaximum display width. Defaults to 320.
screen_height:intMaximum display height. Defaults to 320.
buffer_size:intSize of each decode buffer. Defaults to 1024 * 8.
buffer_num:intNumber of decode buffers. Defaults to 2.
def draw(self, x: int, y: int, file_path, storage=None) -> bool:

Draw a JPEG file at position (x, y) on the display.

Parameters
x:intHorizontal draw position in pixels.
y:intVertical draw position in pixels.
file_path:strPath to the .jpg / .jpeg file.
storageStorage class instance. Defaults to None.
Returns
boolTrue on success, False on failure.
def draw_buffer(self, x: int, y: int, buf) -> bool:

Draw a JPEG image from bytes data into a BytesIO buffer.

Parameters
x:intHorizontal draw position in pixels.
y:intVertical draw position in pixels.
bufBytes data containing the JPEG image.
Returns
boolTrue on success, False on failure.
def _cleanup(self):

Wait for the decoder core and reset the running flag.

def _decode_split(self, fi, fsize, x, y) -> bool:

Decode a JPEG from a file, streaming buffers as needed.

Parameters
fiThe file object to read from.
fsizeThe total file size.
x:intHorizontal draw position.
y:intVertical draw position.
Returns
boolTrue on success, False on failure.
def _get_option(self, scale) -> int:

Return the decoder option for the given scale factor.

Parameters
scaleThe scale factor (1, 0.5, 0.25, or 0.125).
Returns
intThe decoder option value.
def _get_scale(self, w, h) -> tuple[float, tuple[int, int]]:

Return (scale, (auto_x, auto_y)) so the image fits the display.

Parameters
w:intThe image width.
h:intThe image height.
Returns
tuple[float, tuple[int, int]]The scale and auto offset.
def _init_buffers(self):

Allocate the file buffer and split it into decode buffers.

def _read_into_buf(self, fi, buf):

Read data from the file into a buffer.

Parameters
fiThe file object to read from.
bufThe buffer to fill.
def _start_split(self, fsize, buf, x, y) -> bool:

Start decoding a JPEG from the given buffer.

Parameters
fsizeThe total file size.
bufThe initial buffer data.
x:intHorizontal draw position.
y:intVertical draw position.
Returns
boolTrue if decoding started successfully.
def _test_buffer(self, ipos, ilen) -> tuple[int, int]:

Check which buffers cover the requested data range.

Parameters
iposThe requested start position.
ilenThe requested length.
Returns
tuple[int, int]The matching buffer index and free buffer mask.
_buffer_num =

Undocumented

_buffer_size =

Undocumented

_buffers =

Undocumented

_buffers_len =

Undocumented

_buffers_pos =

Undocumented

_decoder_running: bool =

Undocumented

_filebuffer =

Undocumented

_max_height =

Undocumented

_max_width =

Undocumented