private static BitMap2d GetSingleRegionBitmap(BitMap2d b)
        {
            BitMap2d            bmp   = new BitMap2d(b.width, b.height, BitMap2d.WHITE);
            Queue <Int16Double> queue = new Queue <Int16Double>();

            queue.Enqueue(new Int16Double(0, 0));
            bmp.SetPixel(0, 0, BitMap2d.BLACK);
            Int16Double[] adj = new Int16Double[4];
            while (queue.Count != 0)
            {
                Int16Double pix = queue.Dequeue();
                InitAdj4(adj, pix.X, pix.Y);
                for (int i = 0; i < 4; i++)
                {
                    Int16Double t = adj[i];
                    if (t.X >= 0 && t.X < bmp.width && t.Y >= 0 && t.Y < bmp.height &&
                        b.GetPixel(t.X, t.Y) == BitMap2d.BLACK && bmp.GetPixel(t.X, t.Y) == BitMap2d.WHITE)
                    {
                        bmp.SetPixel(t.X, t.Y, BitMap2d.BLACK);
                        queue.Enqueue(t);
                    }
                }
            }
            return(bmp);
        }
            public void AddLine(int x1, int y1, int x2, int y2)
            {
                int index1;

                if (mapHash[x1, y1] == -1)
                {
                    index1 = polyline.Points.Count;
                    polyline.Points.Add(new FloatDouble(x1, y1));
                    mapHash[x1, y1] = index1;
                }
                else
                {
                    index1 = mapHash[x1, y1];
                }
                int index2;

                if (mapHash[x2, y2] == -1)
                {
                    index2 = polyline.Points.Count;
                    polyline.Points.Add(new FloatDouble(x2, y2));
                    mapHash[x2, y2] = index2;
                }
                else
                {
                    index2 = mapHash[x2, y2];
                }
                Int16Double line = new Int16Double(index1, index2);

                polyline.Edges.Add(line);
            }
 public PolyLine GenerateLine()
 {
     Int16Double[] adj = new Int16Double[4];
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             if (bmp.GetPixel(i, j) != BitMap2d.WHITE)
             {
                 continue;
             }
             InitAdj4(adj, i, j);
             for (int k = 0; k < 4; k++)
             {
                 Int16Double t = adj[k];
                 if (bmp.GetPixel(t.X, t.Y) != BitMap2d.WHITE)
                 {
                     Int16Double v1d = AdjIndexToEdge[k][0];
                     Int16Double v2d = AdjIndexToEdge[k][1];
                     int         x1  = i + v1d.X;
                     int         y1  = j + v1d.Y;
                     int         x2  = i + v2d.X;
                     int         y2  = j + v2d.Y;
                     pb.AddLine(x1, y1, x2, y2);
                 }
             }
         }
     }
     return(pb.GetLine());
 }