2007.07.12 15:21 "[Tiff] how to rotate an image", by Oliver Geisen

2007.07.14 16:03 "Re: [Tiff] Re: Bit shifting and rotating of TIFF images", by Bob Friesenhahn

I look around to solve the bit-swapping problem and the best solution i found was a lookup table like:

idx   1 = 1000 0000
idx   2 = 1100 0000
idx 254 = 0000 0001

To get the bit-swapped result just use the current pixel-data as an index into this table.

   cswap = lookup[c];

So after byte and bit swapping there must be also be a bit shifting by the amount of remaining bits (1..7).

This is a challenge, even if perfomance does not matter ;-)

I think that with some intense mental focus, you will be able to create the small bit of code necessary to decode a scanline while writing a new one. This is surely faster when done entirely algorithmically rather than using a lookup table. An algorithmic implementation can be done entirely within the CPU whereas a lookup table needs to go to memory, even if it is to a memory cache.

I recall developing this exact same algorithm in 1983 in assembly language on an 8085 CPU. If I could do it in assembly language, I am sure that you can do it in modern C or C++. :-)

Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/