Ejemplo n.º 1
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     MakeContur();
     Fill();
     RedrawPolygon();
 }
Ejemplo n.º 2
0
 public CurrentTester(FloodFillContext context, PartitionDrawer partitioner)
 {
     Initialize(context, partitioner);
     CreateFloodFiller();
     algorithmsCount = floodFiller.strategiesList.Count;
     testResults = new float[algorithmsCount];
 }
Ejemplo n.º 3
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     yRows = new List<float>[monitorHeight];
     MakeAndSortAEL(yRows);
     Draw();
 }
Ejemplo n.º 4
0
        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);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 7
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     FloodFillHelper(context.FillStartPoint.X, context.FillStartPoint.Y);
 }
Ejemplo n.º 8
0
 private void Initialize(FloodFillContext context, PartitionDrawer partitioner)
 {
     this.context = context;
     this.context.bitmap = context.bitmap.Clone() as Bitmap;
     this.partitioner = partitioner;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
 public override void FloodFill(FloodFillContext context)
 {
     Initialize(context);
     stack.Push(context.FillStartPoint);
     FloodFillHelper();
 }