(width, height, pngdata, attrs)
return picodata
Extracts PICO-8 bytes from a .p8.png's PNG data.

    The arguments are expected in the format returned by png.Reader's
    read() method.

    Args:
        width: The PNG width.
        height: The PNG height.
        pngdata: The PNG data region, an iterable of 'height' rows, where
        each row is an indexable 'width' * 'attrs['planes']' long.
        attrs: The PNG attrs.

    Returns:
        The PICO-8 data, a list of width * height (0x8000) byte-size numbers.
Extracts PICO-8 bytes from a .p8.png's PNG data.
Extracts PICO - 8 bytes from a . p8 . png s PNG data .
def get_picodata_from_pngdata(width, height, pngdata, attrs):
    """Extracts PICO-8 bytes from a .p8.png's PNG data.

    The arguments are expected in the format returned by png.Reader's
    read() method.

    Args:
        width: The PNG width.
        height: The PNG height.
        pngdata: The PNG data region, an iterable of 'height' rows, where
        each row is an indexable 'width' * 'attrs['planes']' long.
        attrs: The PNG attrs.

    Returns:
        The PICO-8 data, a list of width * height (0x8000) byte-size numbers.
    """
    picodata = [0] * width * height

    row_i = 0
    for row in pngdata:
        for col_i in range(width):
            picodata[row_i * width + col_i] |= (
                (row[col_i * attrs['planes'] + 2] & 3) << (0 * 2))
            picodata[row_i * width + col_i] |= (
                (row[col_i * attrs['planes'] + 1] & 3) << (1 * 2))
            picodata[row_i * width + col_i] |= (
                (row[col_i * attrs['planes'] + 0] & 3) << (2 * 2))
            picodata[row_i * width + col_i] |= (
                (row[col_i * attrs['planes'] + 3] & 3) << (3 * 2))
        row_i += 1

    return picodata
def get_picodata_from_pngdata ( width , height , pngdata , attrs ) : picodata = [ 0 ] * width * height row_i = 0 for row in pngdata : for col_i in range ( width ) : picodata [ row_i * width + col_i ] |= ( ( row [ col_i * attrs [ 'planes' ] + 2 ] & 3 ) << ( 0 * 2 ) ) picodata [ row_i * width + col_i ] |= ( ( row [ col_i * attrs [ 'planes' ] + 1 ] & 3 ) << ( 1 * 2 ) ) picodata [ row_i * width + col_i ] |= ( ( row [ col_i * attrs [ 'planes' ] + 0 ] & 3 ) << ( 2 * 2 ) ) picodata [ row_i * width + col_i ] |= ( ( row [ col_i * attrs [ 'planes' ] + 3 ] & 3 ) << ( 3 * 2 ) ) row_i += 1 return picodata