Re: Howto Extract PNG from binary file @ 0x80?
From: flamesrock (flamesrock_at_gmail.com)
Date: 01/04/05
- Next message: Christopher J. Bottaro: "Re: HTTP GET request with basic authorization?"
- Previous message: Steve Holden: "Re: Advice request for project"
- In reply to: Robert Kern: "Re: Howto Extract PNG from binary file @ 0x80?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 3 Jan 2005 18:23:52 -0800
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)
- Next message: Christopher J. Bottaro: "Re: HTTP GET request with basic authorization?"
- Previous message: Steve Holden: "Re: Advice request for project"
- In reply to: Robert Kern: "Re: Howto Extract PNG from binary file @ 0x80?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|