(instr, filename=None)
return data
Read and unpack raw section data from a .p8.png file.

    Args:
        instr: The input stream.
        filename: The filename, if any, for tool messages.

    Returns:
        An object with properties of raw data: gfx, p8map, gfx_props,
                song, sfx, codedata, version, code_length, code,
                compressed_size.
Read and unpack raw section data from a .p8.png file.
Read and unpack raw section data from a . p8 . png file .
def get_raw_data_from_p8png_file(instr, filename=None):
    """Read and unpack raw section data from a .p8.png file.

    Args:
        instr: The input stream.
        filename: The filename, if any, for tool messages.

    Returns:
        An object with properties of raw data: gfx, p8map, gfx_props,
                song, sfx, codedata, version, code_length, code,
                compressed_size.
    """
    # To install: python3 -m pip install pypng
    import png
    try:
        r = png.Reader(file=instr)
        (width, height, data, attrs) = r.read()
        data = list(data)
    except png.Error:
        raise InvalidP8PNGError()

    picodata = get_picodata_from_pngdata(width, height, data, attrs)

    class ParsedData(object):
        pass
    data = ParsedData()

    data.gfx = picodata[0x0:0x2000]
    data.p8map = picodata[0x2000:0x3000]
    data.gfx_props = picodata[0x3000:0x3100]
    data.song = picodata[0x3100:0x3200]
    data.sfx = picodata[0x3200:0x4300]
    data.codedata = picodata[0x4300:0x8000]
    data.version = picodata[0x8000]

    # TODO: Extract new_game.label from data

    (data.code_length, data.code, data.compressed_size) = \
        get_code_from_bytes(data.codedata, data.version)

    return data
def get_raw_data_from_p8png_file ( instr , filename = None ) : # To install: python3 -m pip install pypng import png try : r = png . Reader ( file = instr ) ( width , height , data , attrs ) = r . read ( ) data = list ( data ) except png . Error : raise InvalidP8PNGError ( ) picodata = get_picodata_from_pngdata ( width , height , data , attrs ) class ParsedData ( object ) : pass data = ParsedData ( ) data . gfx = picodata [ 0x0 : 0x2000 ] data . p8map = picodata [ 0x2000 : 0x3000 ] data . gfx_props = picodata [ 0x3000 : 0x3100 ] data . song = picodata [ 0x3100 : 0x3200 ] data . sfx = picodata [ 0x3200 : 0x4300 ] data . codedata = picodata [ 0x4300 : 0x8000 ] data . version = picodata [ 0x8000 ] # TODO: Extract new_game.label from data ( data . code_length , data . code , data . compressed_size ) = get_code_from_bytes ( data . codedata , data . version ) return data