rwfpl / rewolf-mortal-kombat

Mortal Kombat GRA files parser. More details at http://blog.rewolf.pl/blog/?p=1837
16 stars 1 forks source link

Decompression error / ProtocolError #2

Open palmerj opened 1 month ago

palmerj commented 1 month ago

I get the following error when running the script with python 3.11 on MacOS (m2 chip)

❯ python parse.py mk1_dos/GRAPHICS/RAIDEN.GRA 
Number of palette colors: 63575 

Processing frame nr   : 0
Compressed data offset: 0x1f128
Decompression error, exiting.

I tried a number of GRA files and got the same result

palmerj commented 1 month ago

Ok I think that's because that file is a uGRA file. Might be nice to try and detect that or have a list of files we are cGRA files.

This file is creating this error for me:

python parse.py mk1_dos/GRAPHICS/GORO1.GRA 
Number of palette colors: 238 

Processing frame nr   : 0
Compressed data offset: 0x1e8
Compressed data size  : 34734
Decompressed data size: 64000
Frame width           : 320
Frame height          : 200
LZW parameter         : 8
Writing PNG           : /userdata/system/tmp/GORO1_00.png
Traceback (most recent call last):
  File "/userdata/system/tmp/parse.py", line 106, in <module>
    png.from_array(png_array, 'RGB').save(file_name)
  File "/usr/lib/python3.11/site-packages/png.py", line 1299, in save
    w.write(fd, self.rows)
  File "/usr/lib/python3.11/site-packages/png.py", line 668, in write
    nrows = self.write_passes(outfile, check_rows(rows))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/png.py", line 703, in write_passes
    return self.write_packed(outfile, rows)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/png.py", line 738, in write_packed
    for i, row in enumerate(rows):
  File "/usr/lib/python3.11/site-packages/png.py", line 658, in check_rows
    raise ProtocolError(
png.ProtocolError: ProtocolError: Expected 318 values but got 320 values, in row 0