bit manipulation frustration

Courageous jkraska1 at san.rr.com
Sun Jul 23 00:56:20 EDT 2000


> > vice versa. Eeek. Help? Will someone please remind me and
> > hit me with a rubber mallet??? :)

> ... is one way. There are probably others. Consider youself whalloped.

Yeah, amongst all the various documentation, I finally found my
way to FAQTS. It was:

>>> l=list("fred")
>>> l
['f', 'r', 'e', 'd']
>>> string.join(l,"")
'fred'
>>> 

> > Second, this whole paradigm seems so skrewball.
> ...
> > get it?)

Um, well suppose I do something like...

            myfile.seek ( 2000, 0 )
            str = myfile.read (20)

This will result in a sequence of 20 bytes ('char'),
But these are 16 bit RGB values (1 pad, 5/5/5 R/G/B).
In C, I would quite possibly load these into ints,
as 16 bit values straight up, and manipulate them that
way. Now while I understand that I can unpack into
16 bit integers, manipulate, and then pack back to
char all via the struct module, this is seeming like
a great deal of transmogrification.

Say for example I want to increase or decrease R,
G, or B values. Or, say, I want to convert to 32
bit color bitmaps?



C/



More information about the Python-list mailing list