Re: Howto Extract PNG from binary file @ 0x80?

2005-01-03 Thread flamesrock
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 8byte

Re: Howto Extract PNG from binary file @ 0x80?

2005-01-03 Thread Robert Kern
Don't seek to position 97. Seek to 96. You're off by one. That's why there's the test for the header (which you removed). Files (and Python strings for that matter) are 0-indexed. The first character is 0, the second 1, and so on. If you want the 97th character, you have to seek to position 96.

Re: Howto Extract PNG from binary file @ 0x80?

2005-01-03 Thread flamesrock
Hmm...I'm not sure exactly. One of the things I've read is that sometimes stuff is compressed in a savegame file, but I don't know why they'd do that with a png.. I have some code that does the exact same thing in php only I don't understand php syntax and how they did it. Does it give any clues a

Re: Howto Extract PNG from binary file @ 0x80?

2005-01-03 Thread Robert Kern
flamesrock wrote: [snip] [EMAIL PROTECTED]:~/score$ python sc4png.py Traceback (most recent call last): File "sc4png.py", line 26, in ? pngcopy(infile, outfile) File "sc4png.py", line 14, in pngcopy size, cid = struct.unpack("!l4s", chunk) struct.error: unpack str size does not match format Any ide

Re: Howto Extract PNG from binary file @ 0x80?

2005-01-03 Thread flamesrock
Well, I've been working on getting this code to work, and I think I *almost* have it... First, according to ghex, it seems the PNG starts at the 97th byte of the file infile = open("mysimcityfile.sc4", "rb") infile.seek(97) print (infile.read(4)) output: [EMAIL PROTECTED]:~/score$ python sc4png.py

Re: Howto Extract PNG from binary file @ 0x80?

2004-12-22 Thread Aaron
On Sat, 11 Dec 2004 10:53:19 +0100, Fredrik Lundh wrote: > "flamesrock" <[EMAIL PROTECTED]> wrote: > >> As a newbie to the language, I have no idea where to start..please bare >> with me.. >> >> The simcity 4 savegame file has a png image stored at the hex location >> 0x80. What I want to extract

Re: Howto Extract PNG from binary file @ 0x80?

2004-12-11 Thread Fredrik Lundh
"flamesrock" <[EMAIL PROTECTED]> wrote: > As a newbie to the language, I have no idea where to start..please bare > with me.. > > The simcity 4 savegame file has a png image stored at the hex location > 0x80. What I want to extract it and create a file with the .png > extension in that directory.

Howto Extract PNG from binary file @ 0x80?

2004-12-11 Thread flamesrock
Hi, As a newbie to the language, I have no idea where to start..please bare with me.. The simcity 4 savegame file has a png image stored at the hex location 0x80. What I want to extract it and create a file with the .png extension in that directory. Can somebody explain with a snippet of code ho