}
pin_1 += oldData.Stride - oldData.Width * 3;
pin_2 += oldData.Stride - oldData.Width * 3;
pout += newData.Stride - newData.Width * 3;
}
//这里博主加粗了一下线条- -,不喜欢的同学可以删了这段代码
byte* pin_5 = (byte*)(newData.Scan0.ToPointer());
for (int y = 0; y < oldData.Height - 1; y++)
{
for (int x = 3; x < oldData.Width; x++)
{
if(pin_5[0]==0&&pin_5[1]==0&&pin_5[2]==0)
{
pin_5[-3] = 0;
pin_5[-2] = 0;
pin_5[-1] = 0; //边缘点的前一个像素点置为黑色(注意一定要是遍历过的像素点)
}
pin_5 += 3;
}
pin_5 += newData.Stride - newData.Width * 3;
}
//这段代码是把原图和边缘图重合
byte* pin_3= (byte*)(oldData.Scan0.ToPointer());
byte* pin_4 = (byte*)(newData.Scan0.ToPointer());
for (int y = 0; y < oldData.Height - 1; y++)
{
for (int x = 0; x < oldData.Width; x++)
{
if (pin_4[0] == 255 && pin_4[1]==255 && pin_4[2]==255)
{
pin_4[0] = pin_3[0];
pin_4[1] = pin_3[1];
pin_4[2] = pin_3[2];
}
pin_3 += 3;
pin_4 += 3;
}
pin_3 += oldData.Stride - oldData.Width * 3;
pin_4 += newData.Stride - newData.Width * 3;
}
//......
bitmap.UnlockBits(newData);
MyBitmap.UnlockBits(oldData);
this.pBox.Image = bitmap;
}
}
}
例子1: