2007.08.07 05:02 "Re: [Tiff] bilevel image scrambling when size not divisible by 8", by Bob Friesenhahn
On Mon, 6 Aug 2007, Lee Cooper wrote:
Apparently I have some misunderstanding about how bilevel images are handled in TIFF but I can't find much info on the subject. When the number of pixels isn't a multiple of eight how is the remainder of the byte handled? I feel like this will probably be a simple answer but I'm stuck and really need to make some progress. I've included some code snippets below.
The problem you are encountering is that a strip is just a collection of rows (see description of compression tag 259, value 1 on page 17 of the specification) and each row is padded to the next byte boundary. This means that each row is split to a new byte, and any unused bits in the last byte of the scanline should be set to zero.
Your algorithm is nice and compact but it lacks knowledge of rows.
In order to save some effort, you might consider using the TIFFWriteScanline() interface instead. It performs well and is row based.
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/