Reverse order of bit in repeating seqence of byte string

Terry Reedy tjreedy at udel.edu
Fri Jan 2 16:08:57 EST 2009


imageguy wrote:
> I am looking for the most efficient method of replacing a repeating
> sequence in a byte string returned from a imaging .dll, connected via
> 
> I receive the byte string with the following sequence 'bgrbgrbgrbgr'
> and I would like to convert this to 'rbgrbgrbgrbg'

For speed, I would look at PIL or pygame for existing function, or use 
numpy -- read into 2-d array, swap first and third members, flatten.




More information about the Python-list mailing list