bit manipulation frustration

Peter Schneider-Kamp peter at schneider-kamp.de
Sun Jul 23 04:02:45 EDT 2000


Courageous wrote:
> 
> 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?

Oh yes:

>>> def from16to32(v):
...   i = (ord(v[1]) << 8) + ord(v[0])
...   return chr(i >> 11)+chr((i >> 5) & 63)+chr(i & 31)+'\000'
...

Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list