Howto Extract PNG from binary file @ 0x80?
flamesrock
flamesrock at gmail.com
Mon Jan 3 21:23:52 EST 2005
omg, it works!! thankyou!!!!!
and thankyou again, Frederick for the original code!
I've discovered a weird thing when changing header = infile.read(8) to
header = infile.read(4):
For some reason, the extracted png image is the exact same size as the
savegame archive (10.1 megs.) When reading 8bytes, its closer to
~200kb. Any clue as to why that is?
-thanks
#import struct
#
#def pngcopy(infile, outfile):
#
# # copy header
# header = infile.read(8)
# if header != "\211PNG\r\n\032\n":
# raise IOError("not a valid PNG file")
# outfile.write(header)
#
# # copy chunks, until IEND
# while 1:
# chunk = infile.read(8)
# size, cid = struct.unpack("!l4s", chunk)
# outfile.write(chunk)
# outfile.write(infile.read(size))
# outfile.write(infile.read(4)) # checksum
# if cid == "IEND":
# break
#
#
#infile = open("mysimcityfile.sc4", "rb")
#infile.seek(96)
###print (infile.read(4))
#outfile = open("myimage.png", "wb")
#pngcopy(infile, outfile)
#outfile.close()
#infile.close()
(http://simcitysphere.com/peachville.sc4)
More information about the Python-list
mailing list