I'm using the libtiff.net library to encode bytes from a twain complaint scanner with the below tags.
Scanner Settings
_twain32.SetCap(TwCap.IUnits, TwUnits.Inches);
_twain32.SetCap(TwCap.IPixelType, TwPixelType.BW);
_twain32.SetCap(TwCap.BitDepth, 1);
Tiff Settings
_tiffOutput = Tiff.Open(fileName, "w");
_tiffOutput.SetField(TiffTag.IMAGEWIDTH, width);
_tiffOutput.SetField(TiffTag.IMAGELENGTH, length);
_tiffOutput.SetField(TiffTag.IMAGEWIDTH, width);
_tiffOutput.SetField(TiffTag.SAMPLESPERPIXEL, 1);
_tiffOutput.SetField(TiffTag.BITSPERSAMPLE, 1);
_tiffOutput.SetField(TiffTag.ROWSPERSTRIP, length);
_tiffOutput.SetField(TiffTag.XRESOLUTION, dpiX);
_tiffOutput.SetField(TiffTag.YRESOLUTION, dpiY);
_tiffOutput.SetField(TiffTag.SUBFILETYPE, 0);
_tiffOutput.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
_tiffOutput.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
_tiffOutput.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISWHITE);
_tiffOutput.SetField(TiffTag.COMPRESSION, Compression.CCITTFAX4);
_tiffOutput.SetField(TiffTag.GROUP4OPTIONS, Group3Opt.FILLBITS);
_tiffOutput.SetField(TiffTag.FILLORDER, FillOrder.LSB2MSB);
The problem I'm having is with _tiffOutput.SetField(TiffTag.GROUP4OPTIONS, Group3Opt.FILLBITS);
it's not filling to the byte boundary, as according to
https://bitmiracle.github.io/libtiff.net/html/e00d6851-cf09-287f-638b-fc62c498351a.htm and https://bitmiracle.github.io/libtiff.net/html/004b29cb-3828-19ac-b924-95671b477f08.htm.
The image is displayed correctly when viewed and no errors are produced. I also use AWare Systems TiffTagViewer to verify the tiff image after processing. The Compression[Group 4 Fax (CCITTFAX4)] and Group4Options[4 (FILLBITS)] have been verified correct however the ImageWidth and ImageLength do not land on the byte boundary.
Can anyone see what I'm missing?