public void LoadTileset(string path, bool horizontalMirror = true, string debugFilePath = null, bool hasSpacing = false) { //Chop up tileset Bitmap tilesetImg = Image.FromFile(path) as Bitmap; if (horizontalMirror) { tilesetImg = tilesetImg.AddHorizontalMirror(hasSpacing); } _tileset = BitmapOperations.GetBitmapTiles(tilesetImg, _tileWidth, _tileHeight, hasSpacing); if (debugFilePath != null) { Bitmap quickcheck = BitmapOperations.CreateBitmapFromTiles(_tileset, true); BitmapOperations.SaveBitmapToFile(debugFilePath, quickcheck); } //setup wfcTiles (and neighbors) var distinctTiles = GetDistinctBitmaps(_tileset); //why does this mess things up //distinctTiles.AddRange(GetWeightedTiles(_tileWidth, _tileHeight, hasSpacing)); //List<List<Bitmap>> distinctElements = new List<List<Bitmap>>(); //distinctElements.Add(distinctTiles); _wfcTiles = ToOpinionatedList(distinctTiles); SetAcceptableItems(_wfcTiles, _tileset); }
private List <List <Bitmap> > ChopUpTilesWithMirror2D(Bitmap img) { List <Bitmap> result = new List <Bitmap>(); Bitmap tilesetImg = img.AddHorizontalMirror(true); var tiles = BitmapOperations.GetBitmapTiles(tilesetImg, 6, 6, true); return(tiles); }
private List <List <Bitmap> > ChopUpTilesWithMirror2D(string tilespath) { List <Bitmap> result = new List <Bitmap>(); Bitmap tilesetImg = LoadBmp(tilespath); tilesetImg = tilesetImg.AddHorizontalMirror(true); var tiles = BitmapOperations.GetBitmapTiles(tilesetImg, 6, 6, true); return(tiles); }
private List <Bitmap> ChopUpTiles(Bitmap img) { List <Bitmap> result = new List <Bitmap>(); var tiles = BitmapOperations.GetBitmapTiles(img, 6, 6, true); foreach (var row in tiles) { result.AddRange(row); } return(result); }
private List <OpinionatedItem <Bitmap> > getWcfTilesInBmp(string path, bool hasSpacing = false) { Bitmap bmp = Image.FromFile(path) as Bitmap; List <List <Bitmap> > tileset = BitmapOperations.GetBitmapTiles(bmp, _tileWidth, _tileHeight, hasSpacing); List <Bitmap> tiles = new List <Bitmap>(); foreach (var list in tileset) { tiles.AddRange(list); } return(_wfcTiles.Where(element => tiles.Any(t => BitmapOperations.Compare(t, element.actualItem))).ToList()); }
private List <Bitmap> ChopUpTiles(string tilespath) { Console.WriteLine("ChoppingUpTiles at " + tilespath); List <Bitmap> result = new List <Bitmap>(); Bitmap tilesetImg = LoadBmp(tilespath); var tiles = BitmapOperations.GetBitmapTiles(tilesetImg, 6, 6, true); foreach (var row in tiles) { result.AddRange(row); } return(result); }
public List <Bitmap> GetWeightedTiles(int _tileWidth, int _tileHeight, bool hasSpacing = false) { List <Bitmap> result = new List <Bitmap>(); var weight = 10; Bitmap tilesetIMg = Image.FromFile(ConfigurationManager.AppSettings["TenXWeightedTiles"].ToString()) as Bitmap; _tileset = BitmapOperations.GetBitmapTiles(tilesetIMg, _tileWidth, _tileHeight, hasSpacing); for (var i = 0; i < weight; i++) { foreach (var verticalRow in _tileset) { result.AddRange(verticalRow); } } return(result); }
private List <Bitmap> ChopUpTilesWithMirror(Bitmap img) { List <Bitmap> result = new List <Bitmap>(); var tilesImg = img.AddHorizontalMirror(true); var tiles = BitmapOperations.GetBitmapTiles(tilesImg, 6, 6, true); //bad form var path = TilesetDebugFolderPath; if (path != null) { BitmapOperations.SaveBitmapToFile(path + /*"../../TilesetsDebug/Current/" +*/ "mainTilesetDebug" + ".bmp", BitmapOperations.CreateBitmapFromTiles(tiles, true)); } foreach (var row in tiles) { result.AddRange(row); } return(result); }
public void LoadTileset(string path, bool horizontalMirror = true) { //Chop up tileset Bitmap tilesetImg = Image.FromFile(path) as Bitmap; if (horizontalMirror) { tilesetImg = tilesetImg.AddHorizontalMirror(); } _tileset = BitmapOperations.GetBitmapTiles(tilesetImg, _tileWidth, _tileHeight); //setup wfcTiles (and neighbors) var distinctTiles = GetDistinctBitmaps(_tileset); //List<List<Bitmap>> distinctElements = new List<List<Bitmap>>(); //distinctElements.Add(distinctTiles); _wfcTiles = ToOpinionatedList(distinctTiles); SetAcceptableItems(_wfcTiles, _tileset); }
private void GetBitmapGrid() { TileGrid = BitmapOperations.GetBitmapTiles(Input, TileDim.X, TileDim.Y, false); }
private static void Execute() { Bitmap tileset = Image.FromFile(ConfigurationManager.AppSettings["TilesetInput"]) as Bitmap; tileset = tileset.AddHorizontalMirror(); List <List <Bitmap> > tiles = BitmapOperations.GetBitmapTiles(tileset, 5, 5); Bitmap hTraverseBmp = Image.FromFile(ConfigurationManager.AppSettings["hTraverseInput"]) as Bitmap; List <List <Bitmap> > hTraverseDbl = BitmapOperations.GetBitmapTiles(hTraverseBmp, 5, 5); Bitmap quickcheck = BitmapOperations.CreateBitmapFromTiles(hTraverseDbl, true); BitmapOperations.SaveBitmapToFile(ConfigurationManager.AppSettings["TilesetOutput"], quickcheck); List <Bitmap> hTraverse = new List <Bitmap>(); foreach (var list in hTraverseDbl) { hTraverse.AddRange(list); } Bitmap vTraverseBmp = Image.FromFile(ConfigurationManager.AppSettings["vTraverseInput"]) as Bitmap; List <List <Bitmap> > vTraverseDbl = BitmapOperations.GetBitmapTiles(vTraverseBmp, 5, 5); List <Bitmap> vTraverse = new List <Bitmap>(); foreach (var list in vTraverseDbl) { vTraverse.AddRange(list); } var distinctTiles = GetDistinctBitmaps(tiles); List <List <Bitmap> > distinctElements = new List <List <Bitmap> >(); distinctElements.Add(distinctTiles); Bitmap tilemapWithSpacing = BitmapOperations.CreateBitmapFromTiles(distinctElements, true); BitmapOperations.SaveBitmapToFile(ConfigurationManager.AppSettings["TilesetOutput"], tilemapWithSpacing); var opinionatedItemsDistinct = ToOpinionatedList(distinctTiles); SetAcceptableItems(opinionatedItemsDistinct, tiles); var vTraverseOpinionated = opinionatedItemsDistinct.Where(element => vTraverse.Any(bmp => BitmapOperations.Compare(bmp, element.actualItem))).ToList(); var hTraverseOpinionated = opinionatedItemsDistinct.Where(element => hTraverse.Any(bmp => BitmapOperations.Compare(bmp, element.actualItem))).ToList(); for (var i = 0; i < 5; i++) { var wcf = new WcfGrid(); wcf.Init(20, 10, 1, opinionatedItemsDistinct); List <WcfVector> shape = WcfVector.GetCross3dShape(); wcf.SetInfluenceShape(shape); //Manual Edits //in and out AddDoor(wcf, opinionatedItemsDistinct[1], 5); //border AddBorder(wcf, opinionatedItemsDistinct[0], 5); //add path AddPath(wcf, hTraverseOpinionated, 5); var result = wcf.CollapseAllRecursive(); //if (result == false) //continue; var collapsedTiles = ToTilesList(wcf); wcf.PrintStatesToConsole2d(); Bitmap tilesetRedux = BitmapOperations.CreateBitmapFromTiles(collapsedTiles); BitmapOperations.SaveBitmapToFile( ConfigurationManager.AppSettings["BitmapOutput"].Replace( ".bmp", i.ToString() + ".bmp" ), tilesetRedux); } }