public Image EraseLines(Bitmap targetImg, Color color, List <Rectangle> Regions) { if (Regions.Count == 0) { return(EraseLines(targetImg, color)); } Counter counter = new Counter(this.outputHanler); counter.Start("EraseLines"); //水平線 Bitmap newImg = targetImg.Clone(new Rectangle(0, 0, targetImg.Width, targetImg.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); LockBitmap imgLocker = new LockBitmap(newImg); imgLocker.LockBits(); //TestGetPixle(imgLocker); List <MergeLineInfo> Hlines = ScanLines(imgLocker, LineDirction.Horizontal); //縦線 List <MergeLineInfo> Vlines = ScanLines(imgLocker, LineDirction.Vertical); imgLocker.UnlockBits(); using (Graphics g = Graphics.FromImage(newImg)) { EraseAllLines(g, Hlines, Vlines, Regions); } counter.End(); return(newImg); }
public Image EraseLines(Bitmap targetImg, Color color) { Counter counter = new Counter(this.outputHanler); counter.Start("EraseLines"); //水平線 Bitmap newImg = targetImg.Clone(new Rectangle(0, 0, targetImg.Width, targetImg.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); LockBitmap imgLocker = new LockBitmap(newImg); imgLocker.LockBits(); //TestGetPixle(imgLocker); List <MergeLineInfo> Hlines = ScanLines(imgLocker, LineDirction.Horizontal); //縦線 List <MergeLineInfo> Vlines = ScanLines(imgLocker, LineDirction.Vertical); EraseAllLines(color, imgLocker, Hlines, Vlines); imgLocker.UnlockBits(); counter.End(); return(newImg); }
public Image DrawLineRects(Bitmap orgImg, Color color) { //水平線 Bitmap newImg = orgImg.Clone(new Rectangle(0, 0, orgImg.Width, orgImg.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); LockBitmap imgLocker = new LockBitmap(newImg); imgLocker.LockBits(); List <MergeLineInfo> Hlines = ScanLines(imgLocker, LineDirction.Horizontal); //縦線 List <MergeLineInfo> Vlines = ScanLines(imgLocker, LineDirction.Vertical); imgLocker.UnlockBits(); Bitmap drawImg = new Bitmap(newImg); //水平線描画 Hlines.ForEach(l => l.DrawRect(drawImg)); //縦線描画 Vlines.ForEach(l => l.DrawRect(drawImg)); return(drawImg); }