public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     MakeContur();
     Fill();
     RedrawPolygon();
 }
Beispiel #2
0
 public CurrentTester(FloodFillContext context, PartitionDrawer partitioner)
 {
     Initialize(context, partitioner);
     CreateFloodFiller();
     algorithmsCount = floodFiller.strategiesList.Count;
     testResults = new float[algorithmsCount];
 }
Beispiel #3
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     yRows = new List<float>[monitorHeight];
     MakeAndSortAEL(yRows);
     Draw();
 }
        public override void FloodFill(FloodFillContext context)
        {
            Initialize(context);

            PointF currentPoint;
            int currentY;
            Rectangle bounds = data.GetPolygonBounds();
            int currentColor;
            int xMin = bounds.Left, xMax = bounds.Right;
            foreach (KeyValuePair<Point, Point> edge in data.GetAllEdges())
            {
                for (EdgePixelsIterator iterator = new EdgePixelsIterator(edge); !iterator.End(); iterator.Next())
                {
                    currentPoint = iterator.Current();
                    if (!currentPoint.IsEmpty)
                    {
                        currentY = (int)(currentPoint.Y - 0.5);
                        for (int currentX = (int)Math.Ceiling(currentPoint.X); currentX < xMax; ++currentX)
                        {
                            currentColor = GetPixel(currentX, currentY);
                            if (currentColor != aBorderColor)
                            {
                                if (currentColor == aBackColor)
                                    SetPixel(currentX, currentY, fillColor);
                                else
                                    SetPixel(currentX, currentY, backColor);
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public void FloodFill(Image currentImage, Color fillColor, Color polygonColor, Color backColor, Point fillStartPoint)
 {
     LastBitmap = currentImage.Clone() as Bitmap;
     FloodFillContext context = new FloodFillContext(currentImage as Bitmap, data, fillStartPoint, polygonColor, fillColor, backColor);
     CreateWorker(context.bitmap);
     floodFillerStrategy.SlowMode = _EnableSlowing;
     worker.RunWorkerAsync(context);
 }
Beispiel #6
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     var graphics = System.Drawing.Graphics.FromImage(bmp);
     foreach (KeyValuePair<Point, Point> edge in data.GetAllEdges())
     {
         graphics.DrawLine(new Pen(backColor), edge.Key, edge.Value);
         DrawLineDDA(edge.Key, edge.Value);
     }
     Fill();
 }
Beispiel #7
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     FloodFillHelper(context.FillStartPoint.X, context.FillStartPoint.Y);
 }
Beispiel #8
0
 private void Initialize(FloodFillContext context, PartitionDrawer partitioner)
 {
     this.context = context;
     this.context.bitmap = context.bitmap.Clone() as Bitmap;
     this.partitioner = partitioner;
 }
Beispiel #9
0
 public void RefreshData(FloodFillContext context, PartitionDrawer partitioner)
 {
     Initialize(context, partitioner);
 }
        public override void FloodFill(FloodFillContext context)
        {
            Initialize(context);

            PointF currentPoint;
            int currentY;
            Rectangle bounds = data.GetPolygonBounds();
            int currentColor;
            int xMin = bounds.Left, xMax = bounds.Right;
            int yMin = bounds.Top, yMax = bounds.Bottom;
            float K = GetPartitionLineCoefK(), B = GetPartitionLineCoefB();
            int startX, endX;

            foreach (KeyValuePair<Point, Point> edge in data.GetAllEdges())
            {
                for (EdgePixelsIterator iterator = new EdgePixelsIterator(edge); !iterator.End(); iterator.Next())
                {
                    currentPoint = iterator.Current();
                    if (!currentPoint.IsEmpty)
                    {
                        currentY = (int)(currentPoint.Y - 0.5);
                        if (K != float.MaxValue)
                        {
                            if ((K * currentPoint.X + B - currentPoint.Y) * (K * xMin + B - yMin) > 0)
                            {
                                startX = (int)Math.Ceiling(currentPoint.X);
                                endX = (int)Math.Ceiling((currentPoint.Y - B) / K);
                            }
                            else
                            {
                                startX = (int)Math.Ceiling((currentPoint.Y - B) / K);
                                endX = (int)Math.Ceiling(currentPoint.X);
                            }
                        }
                        else
                        {
                            if (currentPoint.X < partitionBegin.X)
                            {
                                startX = (int)Math.Ceiling(currentPoint.X);
                                endX = partitionBegin.X;
                            }
                            else
                            {
                                startX = partitionBegin.X;
                                endX = (int)Math.Ceiling(currentPoint.X);
                            }
                        }
                        for (int currentX = startX; currentX < endX; ++currentX)
                        {
                            currentColor = GetPixel(currentX, currentY);
                            if (currentColor != aBorderColor)
                            {
                                if (currentColor == aBackColor)
                                    SetPixel(currentX, currentY, fillColor);
                                else
                                    SetPixel(currentX, currentY, backColor);
                            }
                        }
                    }
                }
            }
            System.Drawing.Graphics.FromImage(bmp).DrawLine(new Pen(fillColor), partitionBegin, partitionEnd);
        }
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     stack.Push(context.FillStartPoint);
     FloodFillHelper();
 }