BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
AbstractFloodFiller.cs
Go to the documentation of this file.
1using System.Diagnostics;
2using AForge;
3using Color = AForge.Color;
4using RectangleD = AForge.RectangleD;
5using Point = AForge.Point;
6namespace BioCore
7{
12 public abstract class AbstractFloodFiller
13 {
14
15 protected Bitmap bitmap;
16 protected ColorS tolerance = new ColorS(25, 25, 25);
17 protected ColorS fillColor = ColorS.FromColor(Color.Black);
18 protected bool fillDiagonally = false;
19 protected bool slow = false;
20
21 //cached bitmap properties
22 protected int bitmapWidth = 0;
23 protected int bitmapHeight = 0;
24 protected int bitmapStride = 0;
25 protected int bitmapPixelFormatSize = 0;
26 protected byte[] bitmapBits = null;
28
29 //internal int timeBenchmark = 0;
30 internal Stopwatch watch = new Stopwatch();
31
32 //internal, initialized per fill
33 //protected BitArray pixelsChecked;
34 protected bool[] pixelsChecked;
35 protected ColorS byteFillColor;
36 protected ColorS startColor;
37 //protected int stride;
38
40 {
41
42 }
43
45 {
46 if (configSource != null)
47 {
48 this.Bitmap = configSource.Bitmap;
49 this.FillColor = configSource.FillColor;
50 this.FillDiagonally = configSource.FillDiagonally; ;
51 this.Tolerance = configSource.Tolerance;
52 }
53 }
54
55 public ColorS FillColor
56 {
57 get { return fillColor; }
58 set { fillColor = value; }
59 }
60
61 public bool FillDiagonally
62 {
63 get { return fillDiagonally; }
64 set { fillDiagonally = value; }
65 }
66
67 public ColorS Tolerance
68 {
69 get { return tolerance; }
70 set { tolerance = value; }
71 }
72
74 {
75 get { return bitmap; }
76 set
77 {
78 bitmap = value;
79 }
80 }
81
82 public abstract void FloodFill(Point pt);
83 protected void PrepareForFloodFill(Point pt)
84 {
85 startColor = bitmap.GetPixel((int)pt.X, (int)pt.Y);
86 byteFillColor = new ColorS(fillColor.B, fillColor.G, fillColor.R);
87 bitmapStride = bitmap.Stride;
88 bitmapPixelFormatSize = bitmap.PixelFormatSize;
89 pixelFormat = bitmap.PixelFormat;
90 bitmapBits = bitmap.Bytes;
91 bitmapWidth = bitmap.SizeX;
92 bitmapHeight = bitmap.SizeY;
93 pixelsChecked = new bool[bitmapBits.Length / bitmapPixelFormatSize];
94 }
95 }
96}
System.Drawing.Color Color
AForge.RectangleD RectangleD
Definition ImageView.cs:17
OpenTK.Graphics.OpenGL.PixelFormat PixelFormat
Definition SlideGLArea.cs:8
System.Drawing.Point Point
The base class that the flood fill algorithms inherit from. Implements the basic flood filler functio...
AbstractFloodFiller(AbstractFloodFiller configSource)