Ok i had a method for finding the colours in a bitmap file but its very
inefficient so i will have to go through each bit individually and check
its value. I will have to go through the bytes in the file first i have
the bytes read in........i should only be getting a black and white
value either 255 or 0 but i am getting these other values like 66 in the
byte array........
input = new FileStream(fileName,FileMode.Open,FileAccess.Read) ;
binaryData = new Byte[input.Length];
long bytesRead = input.Read(binaryData, 0,
(int)input.Length);
Bitmap bitmap = (Bitmap)Image.FromFile(fileName);
int Bpheight = bitmap.Height;
int Bpwidth = bitmap.Width;
int widthinbytes = (Bpwidth + 7) /8;
int padding = widthinbytes %4;
for (int biheight=0;biheight < Bpheight;biheight++)
{
for (int width=0; width < widthinbytes; width++)
{
//scan through each bit in a byte
for( int bitpos =7; bitpos >= 0;bitpos--)
{
current_byte_position = (biheight *(widthinbytes + padding)) + width;
int Is_Set = bitvalue(bitpos,binaryData[current_byte_position]);
}
}
}
int bitvalue(int index,byte datarray)
{
byte[] masks = new byte[8];
byte temp = 0x01;
for (int i = 0; i <=7;i++)
{
masks[i] = temp;
temp <<= 1;
}
return(datarray & masks[index])>>index;
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!