BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;//该图像每一行的宽度
System.IntPtr Scan0 = bmData.Scan0;
b.UnlockBits(bmData);
Bitmap newb = new Bitmap(b);//根据b新建一个Bitmap
BitmapData newbmData = newb.LockBits(new Rectangle(0, 0, newb.Width, newb.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
System.IntPtr Scan1 = newbmData.Scan0;//获取图像中第一个像素数据的地址
int nWidth = b.Width * 3; //因为每个象素点有rgb三种颜色的颜色值
int ImageHeight = b.Height;
int ImageWidth = b.Width;
unsafe//这是有指针的非安全代码3
{
byte* p = (byte*)(void*)Scan0;
byte* destp = (byte*)(void*)Scan1;
int nOffset = stride - b.Width * 3;
int iMaxAngle = 90;
int iAngleNumber = 0;
//最大值
Maxvalue maxvalue = new Maxvalue();
//循环变量
int i;
int j;
int off = 0;
int iMaxDistance = 0, iDistance = 0;
iMaxDistance = (int)Math.Sqrt(nWidth * nWidth + ImageHeight * ImageHeight);
int[,] lpTrans = new int[iMaxDistance, iMaxAngle];
//去掉孤立点
for (j = 1; j < ImageHeight - 1; j++)
for (i = 1; i < ImageWidth - 1; i++)
{
off = j * nWidth + i;
if (255 == p[off])//1应该为白色\],即是去掉白色孤立点
{
if (p[off -nWidth- 3] == 0 && p[off - nWidth+ 3] == 0 && p[off - 3] == 0 && p[off +3] == 0 && p[off + nWidth - 3] == 0 && p[off +nWidth+ 3] == 0 && p[off + nWidth ] == 0 && p[off - nWidth ] == 0)
p[off] = 0;
上面这段程序 运行到 最后那个IF语句的时候出现这种错误 请大家帮忙解决