bit manipulation frustration

Courageous jkraska1 at san.rr.com
Sat Jul 22 23:38:39 EDT 2000


Okay. I'm getting a bit frustrated here. I'm trying to suck
bits out of a file (which is in a simple, but non standard
image format) and then convert this to a bitmap for wxPython.
I haven't gotten to the wxBitmap part yet, which I am assuming
will be easy, but the in-between part is driving me nuts.

First, in one fell swoop of antigenious, I seem to have
forgotten how to convert strings to sequences of char and
vice versa. Eeek. Help? Will someone please remind me and
hit me with a rubber mallet??? :)

Second, this whole paradigm seems so skrewball. While I
know exactly how to implement all of this in a external
C module, the program I'm writing is just a one off, and
I was expecting it to be easier in python.

The bitmap image is 16 bit color, but it's stored in
byte runs. As I load the image, I need to load 2,4,6,
8...44,42,40...2, 16 bit chunks at a time, but as I'm
doing this I have to create "black" runs on either side,
making the whole thing 44x44 (it's an isometric tile...
a square rotated 45 degrees, but bitmaps are square,
get it?)

I'm not seeing an elegant solution here; loading the
image as a string to begin with isn't right, because
my chunks are actually two byte chunks.

Anyone with any practical experience on how to *BEST*
do this kind of thing?

Am I just not thinking about this right?




C/



More information about the Python-list mailing list