Binary file Pt 1 - Only reading some
Mastastealth
mastastealth at gmail.com
Mon Feb 4 22:51:24 EST 2008
I'm trying to create a program to read a certain binary format. I have
the format's spec which goes something like:
First 6 bytes: String
Next 4 bytes: 3 digit number and a blank byte
---
Next byte: Height (Number up to 255)
Next byte: Width (Number up to 255)
Next byte: Number 0 - 5
Every 2 bytes after that: Supposedly a number 0000 - 0899?
Anyway, I'm able to do the first 2 objects fine:
a = info.read(6)
b = info.read(4)
Printing both gives me what I mentioned above, a string and a 3 digit
number with a space. However, as I continue, things get trickier.
c = info.read(1)
d = info.read(1)
Printing c and d in this case gives me a block in the SPE output, or
if I run in a DOS prompt, 2 funny symbols. How do I get an integer out
of this? I'll probably need help once I get to the "every 2 byte"
section, but that'll be a separate post.
More information about the Python-list
mailing list