Skip to content

Printing using the run_length_encode gives an error #81

@supercairos

Description

@supercairos

When using the :

def cmd_print_row(img_row):
    # Try to use run-length compression on the image data.
    encoded_img = run_length_encode(img_row)
...

The encoded_img could not be converted to a proper bytearray yieling an out of bound value error.
Looking at the code a bit, It feels like the method :

def encode_run_length_repetition(n, val):
    res = []
    while n > 0x7f:
        res.append(0x7f | (val << 7))
        n -= 0x7f
    if n > 0:
        res.append((val << 7) | n)
    return res

adds 16bits bytes instead of adding 8bits bytes to the array.
Not sure what should be done.
I've tested with my printer to split the 16bits into 2 8bits but I doesn't work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions