Fills the specified point on the bitmap with the currently selected fill color.
28 {
29 watch.Reset();
30 watch.Start();
31
32
34
35 ranges = new FloodFillRangeQueue(((bitmapWidth+bitmapHeight)/2)*5);
36
37
38 int x = (int)pt.X; int y = (int)pt.Y;
39 int idx = CoordsToByteIndex(ref x, ref y);
40 startColor = bitmap.GetPixel((int)pt.X, (int)pt.Y);
41
42 bool[] pixelsChecked=this.pixelsChecked;
43
44
45 LinearFill(ref x, ref y);
46
47
48 while (ranges.Count > 0)
49 {
50
51 FloodFillRange range = ranges.
Dequeue();
52
53
54 int downPxIdx = (bitmapWidth * (range.Y + 1)) + range.StartX;
55 int upPxIdx = (bitmapWidth * (range.Y - 1)) + range.StartX;
56 int upY=range.Y - 1;
57 int downY = range.Y + 1;
58 int tempIdx;
59 for (int i = range.StartX; i <= range.EndX; i++)
60 {
61
62
63 tempIdx = CoordsToByteIndex(ref i, ref upY);
64 if (range.Y > 0 && (!pixelsChecked[upPxIdx]) &&
CheckPixel(ref tempIdx))
65 LinearFill(ref i, ref upY);
66
67
68
69 tempIdx = CoordsToByteIndex(ref i, ref downY);
70 if (range.Y < (bitmapHeight - 1) && (!pixelsChecked[downPxIdx]) &&
CheckPixel(ref tempIdx))
71 LinearFill(ref i, ref downY);
72 downPxIdx++;
73 upPxIdx++;
74 }
75
76 }
77
78 watch.Stop();
79 }
void PrepareForFloodFill(Point pt)
Definition AbstractFloodFiller.cs:95
FloodFillRange Dequeue()
Definition FloodFillRangeQueue.cs:58
bool CheckPixel(ref int px)
Definition QueueLinearFloodFiller.cs:212