Exemplo n.º 1
0
 public LineInfo(int pos, LineDirction lineType)
 {
     this.LineType      = lineType;
     this.Pos           = pos;
     this.Start         = -1;
     this.End           = -1;
     this.MinScanLength = TableEraser.Env.MinScanLength;
 }
Exemplo n.º 2
0
        private int SearchBlackStart(LockBitmap img, int x, int y, int maxLength, LineDirction lineType)
        {
            Color color = lineType == LineDirction.Horizontal ? img.GetPixel(x, y) : img.GetPixel(y, x);

            while (color.ToArgb() != Color.Black.ToArgb() && x < maxLength)
            {
                x++;
                color = lineType == LineDirction.Horizontal ? img.GetPixel(x, y) : img.GetPixel(y, x);
            }
            return(x);
        }
Exemplo n.º 3
0
        private List <MergeLineInfo> ScanLines(LockBitmap img, LineDirction lineType)
        {
            Counter counter = new Counter(outputHanler);

            counter.Start("ScanLines -" + lineType.ToString());
            LineInfo        line      = null;
            List <LineInfo> lines     = new List <LineInfo>();
            int             maxStep   = lineType == LineDirction.Horizontal ? img.Height : img.Width;
            int             maxLength = lineType == LineDirction.Horizontal ? img.Width : img.Height;
            int             ystep     = 1;
            int             xstep     = 1;
            int             bigStep   = Env.HighSpeedStep;

            for (int y = 0; y < maxStep; y += ystep)
            {
                List <LineInfo> currentLines = new List <LineInfo>();
                line = new LineInfo(y, lineType);
                for (int x = 0; x < maxLength; x += xstep)
                {
                    Color color = lineType == LineDirction.Horizontal ? img.GetPixel(x, y) : img.GetPixel(y, x);
                    if (color.ToArgb() != Color.Black.ToArgb())
                    {
                        if (line.Start > -1)
                        {
                            currentLines.Add(line);
                            line = new LineInfo(y, lineType);
                        }
                        xstep = bigStep;
                    }
                    else
                    {
                        if (xstep == bigStep && x > bigStep - 1)
                        {
                            x = SearchBlackStart(img, x - bigStep + 1, y, maxLength, lineType);
                        }
                        xstep = 1;
                        if (line.Start == -1)
                        {
                            line.Start = x;
                            line.End   = x;
                        }
                        else
                        {
                            line.End = x;
                        }
                    }
                }
                if (line.Start != -1)
                {
                    currentLines.Add(line);
                }
                if (currentLines.Count > 0)
                {
                    List <LineInfo> dotLines = MergeDotLine(currentLines, Env.MaxDotSpace);
                    foreach (LineInfo dotLine in dotLines)
                    {
                        if (dotLine.isLine())
                        {
                            lines.Add(dotLine);
                        }
                    }
                }
                currentLines = null;
            }
            counter.End();
            return(GetMergeLines(lines));
        }