Thanks guys, for helping me... however... when I tried JawiB's code, it runs each one 7 times... which I don't want. it should run it once, checking through each one 7 times. here's the updated code...
PHP Code:
unsigned char mask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
int binValue = 0;
int j = 0;
int stride = (imageWidth + 7) / 8;
unsigned char* rowBuff, *pixByte;
for(int k=0; k < imageLength; k++)
{
rowBuff = buf + stride * k;
for(int i=0; i < imageWidth; i++)
{
pixByte = rowBuff + (i / 8);
cout << " -" << (int)*pixByte << "-" << endl;
if(j > 7) j = 0;
binValue = ((*pixByte & mask[j]) ? 1 : 0 );
cout << binValue;
j++;
}
cout << endl;
}
Is my mask wrong? Or is something else wrong?
By the way... I am getting strange results for (int)*pixByte ... sometimes I will get something like one of these: 31, 13, 30, or 63. The rest are 0s and 255s (which they should be). Anyone have an explaination?