iinf 0 Newbie Poster

Dear Friends,
I am using the following code to read colored (24 bit) image into array, but when
I want to read black and white (1 bit image) it gives error

`"AccessViolationException unhandled"` "Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.":



public static bool identifyLine(Bitmap imtooperated)
{
ArrayList blah = new ArrayList();
BitmapData bmData = new BitmapData();
Rectangle rect = new Rectangle(0, 0, imtooperated.Width,
imtooperated.Height);
bmData = imtooperated.LockBits(rect, ImageLockMode.ReadOnly,
imtooperated.PixelFormat);
int stride = bmData.Stride;
int range=0;
unsafe
{
byte* p = (byte*)(void*)bmData.Scan0;
for (int y = 0; y < imtooperated.Width; y++)
{
for (int x = 0; x < imtooperated.Height; x++)
{
blah.Add(p[range]); //here error comes
range++;
}
p += 1;
}
p += stride;
}
imtooperated.UnlockBits(bmData);
return true;
}

Please help.