Пример #1
0
        public void LoadImage(Bitmap image)
        {
            // build dep graph for loading image
            Digraph<TileGenerationRecord> depGraph = MakeDependencyGraph(image.Width, image.Height);
            int nPixelsConsumed = 0;

            foreach (Digraph<TileGenerationRecord>.Vertex v in depGraph.Vertices)
            {
                List<byte[]> positions =
                    GetPredecessorModelPositions(image, 1, v, new byte[] { }, this.maxN, 1, false, false);
                Color thisPixel = image.GetPixel(v.Label.Point.X, v.Label.Point.Y);

                foreach (byte[] pos in positions)
                {
                    if (pos.Length == 0)
                    {
                        this.nullaryModel.Add(thisPixel);
                    }
                    else
                    {
                        int n = pos.Length / 3;
                        SuccessorTileModel model = this.naryModels[n - 1].Get(pos);

                        if (model == null)
                        {
                            model = new SuccessorTileModel();
                            model.Add(thisPixel);
                            this.naryModels[n - 1].Insert(pos, model);
                        }
                        else
                        {
                            model.Add(thisPixel);
                        }
                    }
                }

                nPixelsConsumed++;

                if (nPixelsConsumed % 10000 == 0)
                {
                    Console.Write(".");
                    Console.Out.Flush();
                }
            }

            Console.WriteLine();
        }