110,534
社区成员
发帖
与我相关
我的任务
分享
遍历像素最好用 BitmapData 速度快
不知道这样行不行
List<List<Point>> pointList = new List<List<Point>>();//所有曲线容器
//曲线点容器
List<Point> points = new List<Point>();
//遍历像素
for (int x = 0; x < bit.Width; x++)
{
int cellCount = 0;//该行中是否有记录
for (int y = 0; y < bit.Height; y++)
{
//颜色因拍照原因 可能色素不一致 需要模糊判断
if (bit.GetPixel(x, y) != Color.White)//bit.GetPixel(x, y)=Color.black
{
points.Add(new Point(x, y));
cellCount ++;
}
}
//如果存在一行没有曲线点 表示第x个曲线已经结束 则重新创建曲线点容器
if (cellCount == 0 && points.Count!=0)
{
pointList.Add(points);
points = new List<Point>();//从新创建曲线容器
}
}
// pointList[i]为一个曲线坐标