Mirror imaging binary numbers

Terry Reedy tjreedy at udel.edu
Wed Dec 6 21:03:05 EST 2006


"Craig" <craigtw.online at gmail.com> wrote in message 
news:1165446077.584437.206310 at 73g2000cwn.googlegroups.com...
> Thanks so much for the response.  I have an array of individual bytes
> which will eventually make up a binary bitmap image that is loaded onto
> an LCD screen (1 = black dot, 0 = white dot).  At the moment each byte
> is reversed to what it should be (completely reverse the bit order):
> e.g 00111101 should be 10111100, 11001100 should be 00110011, etc.  It
> is not an int problem as such, it is more a bit level swap if you get
> what I mean.  If you could help that would be great.

Using any of the solutions posted by others, I would first make a 256 byte 
string in which each byte was the bit reversed version of its index.

IE, bitrev = "\x00\x80\x40\xC0.....\xFF"

Then your actual image processing is a simple, quick lookup for each byte.

Terry Jan Reedy






More information about the Python-list mailing list