(picodata, pngdata, attrs)
return new_rows
Encodes PICO-8 bytes into a given PNG's image data.

    Args:
        picodata: The PICO-8 data, a bytearray of 0x8000 bytes.
        pngdata: The PNG image data of the original cart image,
        as an iterable of rows as returned by pypng.
        attrs: The attrs of the original PNG image, as returned by pypng.

    Returns:
        New PNG image data, as an iterable of rows, suitable for writing
        by pypng.
Encodes PICO-8 bytes into a given PNG's image data.
Encodes PICO - 8 bytes into a given PNG s image data .
def get_pngdata_from_picodata(picodata, pngdata, attrs):
    """Encodes PICO-8 bytes into a given PNG's image data.

    Args:
        picodata: The PICO-8 data, a bytearray of 0x8000 bytes.
        pngdata: The PNG image data of the original cart image,
        as an iterable of rows as returned by pypng.
        attrs: The attrs of the original PNG image, as returned by pypng.

    Returns:
        New PNG image data, as an iterable of rows, suitable for writing
        by pypng.
    """
    new_rows = []
    planes = attrs['planes']
    for row_i, row in enumerate(pngdata):
        width = int(len(row) / planes)
        new_row = bytearray(width * planes)
        for col_i in range(width):
            if (row_i * width + col_i) < len(picodata):
                picobyte = picodata[row_i * width + col_i]
                new_row[col_i * planes + 2] = (
                    (row[col_i * planes + 2] & ~3) |
                    (picobyte & 3))
                new_row[col_i * planes + 1] = (
                    (row[col_i * planes + 1] & ~3) |
                    ((picobyte >> 2) & 3))
                new_row[col_i * planes + 0] = (
                    (row[col_i * planes + 0] & ~3) |
                    ((picobyte >> 4) & 3))
                new_row[col_i * planes + 3] = (
                    (row[col_i * planes + 3] & ~3) |
                    ((picobyte >> 6) & 3))
            else:
                for n in range(4):
                    new_row[col_i * planes + n] = (
                        row[col_i * planes + n])
        new_rows.append(new_row)

    return new_rows
def get_pngdata_from_picodata ( picodata , pngdata , attrs ) : new_rows = [ ] planes = attrs [ 'planes' ] for row_i , row in enumerate ( pngdata ) : width = int ( len ( row ) / planes ) new_row = bytearray ( width * planes ) for col_i in range ( width ) : if ( row_i * width + col_i ) < len ( picodata ) : picobyte = picodata [ row_i * width + col_i ] new_row [ col_i * planes + 2 ] = ( ( row [ col_i * planes + 2 ] & ~ 3 ) | ( picobyte & 3 ) ) new_row [ col_i * planes + 1 ] = ( ( row [ col_i * planes + 1 ] & ~ 3 ) | ( ( picobyte >> 2 ) & 3 ) ) new_row [ col_i * planes + 0 ] = ( ( row [ col_i * planes + 0 ] & ~ 3 ) | ( ( picobyte >> 4 ) & 3 ) ) new_row [ col_i * planes + 3 ] = ( ( row [ col_i * planes + 3 ] & ~ 3 ) | ( ( picobyte >> 6 ) & 3 ) ) else : for n in range ( 4 ) : new_row [ col_i * planes + n ] = ( row [ col_i * planes + n ] ) new_rows . append ( new_row ) return new_rows