2004.10.28 12:03 "[Tiff] why does tiffcp::cpSeparateBufToContigBuf takes BYTES_per_sample as parameter?", by Sachin Garg

2004.10.28 17:59 "Re: [Tiff] why does tiffcp::cpSeparateBufToContigBuf takesBYTES_per_sample as parameter?", by Bob Friesenhahn

As far as I can see, they are indeed byte-oriented. This doesn't make any difference when PlanarConfiguration=contiguous, but I guess it will cause problems when PlanarConfig=separate AND bits per sample is not a multiple of eight. If that combination is really important to you, you should write your own code (that's going to be a lot of bit-shifting).

I had written a version (with lots of bit-shifting) but its dead slow, effecting the overall application performance. So just decided to check how libtiff does similar stuff.

Take a look at ImageMagick (http://www.imagemagick.org/) or GraphicsMagick (http://www.graphicsmagick.org/). Source is free for download. The bit-shifting loops should be liftable. Development GraphicsMagick uses a re-usable generic algorithm which usually comes within 30% of the performance (and sometimes matches the performance) of hand-tweaked loops. The exception to this was single-bit samples, so I provided a hand-tweaked implementation for that case.

Bob

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