Beispiel #1
0
        internal static void TileImages()
        {
            List <HoneycombDef> images = HoneycombPaper.GetImageSet().ToList();

            string[] inputImages = images.Select(i => i.FormatFilename()).ToArray();
            inputImages = new string[]
            {
                "46.png",
                "4_10.png",
                "4_20.png",
                "4i.png",
                "64.png",
                "10_4.png",
                "20_4.png",
                "i4.png",
            };

            ImageGrid imageGrid = new ImageGrid();

            imageGrid.Generate(new ImageGrid.Settings()
            {
                //Directory = @"C:\Users\hrn\Documents\roice\2D Tilings\2D Tilings 9-7-15\2D Tilings\bin\Release",
                Directory = @"C:\Users\hrn\Documents\roice\G4G\Figures",
                //Directory = @"./",
                InputImages = inputImages
            });
        }
Beispiel #2
0
        public void Generate()
        {
            string mosaicDir = @"D:\GitHub\TilingBot\TilingBot\working\mosaic";

            string[] files = EnumFiles(new string[] { @"D:\GitHub\TilingBot\TilingBot\working\experiment graveyard\mosaic" });
            //GenImages( mosaicDir, files );
            //return;

            // Load image info.
            mosaicDir = @"D:\GitHub\TilingBot\TilingBot\working\mosaic";
            var images = LoadImages(mosaicDir);
            //return;

            string sourceImage = @"D:\GitHub\TilingBot\TilingBot\working\tet_50.png";
            Bitmap source      = new Bitmap(sourceImage);

            List <string> inputImages = new List <string>();

            for (int x = 0; x < source.Width; x++)
            {
                for (int y = 0; y < source.Height; y++)
                {
                    Color     c       = source.GetPixel(x, y);
                    ImageInfo closest = FindClosest(c, images.Values);
                    closest.Used = true;
                    string fn = Path.GetFileName(closest.Path);
                    inputImages.Add(fn);
                    System.Diagnostics.Trace.WriteLine(fn + "\t" + c.GetBrightness() + "\t" + closest.AvgBrightness + "\t" + c.GetSaturation() + "\t" + closest.AvgSat);
                }
            }

            // Create output image.
            int numTiles = source.Width;
            //numTiles = 10;
            int gridSpace = 30;
            int tileSize  = 300;
            int size      = numTiles * tileSize + (numTiles + 1) * gridSpace;

            ImageGrid.Settings settings = new ImageGrid.Settings()
            {
                Directory   = mosaicDir,
                Rows        = numTiles,
                Columns     = numTiles,
                Width       = size,
                Height      = size,
                hGap        = gridSpace,
                vGap        = gridSpace,
                InputImages = inputImages.ToArray(),
                FileName    = "mosaic.png"
            };

            ImageGrid grid = new ImageGrid();

            grid.Generate(settings);
        }