I tried writing a small test program with your code, and I'm getting EVERYTHING as true. Here is the code:
Code:
int bitonal() {
uint32 imageWidth, imageLength;
int stripMax, stripCount;
unsigned long imageOffset, result, bufferSize;
tsize_t stripSize;
char* fileName = "28.tif";
TIFF* tif = TIFFOpen(fileName, "r");
if (tif) {
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);
m_memoryWidth = (imageWidth + (1/2)) / 8;
m_memoryLength = imageLength;
// Read in the possibly multiple strips
stripSize = TIFFStripSize(tif);
stripMax = TIFFNumberOfStrips(tif);
imageOffset = 0;
bufferSize = m_memoryWidth * m_memoryLength;
m_bufferSize = bufferSize;
unsigned char* buf = new unsigned char[bufferSize];
const unsigned char bit[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
for (stripCount = 0; stripCount < stripMax; stripCount++){
if((result = TIFFReadEncodedStrip (tif, stripCount,
buf + imageOffset,
stripSize)) == -1){
fprintf(stderr, "Read error on input strip number %d\n", stripCount);
exit(42);
}
imageOffset += result;
}
for(int i=0; i < (imageWidth * imageLength); i++)
{
char c = buf[i];
for(int j=0; j < 8; j++)
{
if(c & bit[j])
{
cout << "!";
}
else {
cout << "";
}
}
}
}
return 0;
}
And I have uploaded the image I am working with.