Exemple #1
0
        public byte[] GetAssembledTiledImage(VirtualFileTiledImage image)
        {
            List <Tile> tiles = GetTiles(image);

            byte[] imageData = ConstructTiledImage(tiles);
            return(imageData);
        }
Exemple #2
0
        private List <Tile> GetTiles(VirtualFileTiledImage image)
        {
            List <Tile> tiles = new List <Tile>();

            foreach (var tileFile in image.Tiles)
            {
                var tile = new Tile();
                tile.TileFile  = tileFile;
                tile.PositionX = int.Parse(tileFile.Name[tileFile.Name.Length - 8].ToString());
                tile.PositionY = int.Parse(tileFile.Name[tileFile.Name.Length - 5].ToString());
                var imageData = Extractor.GetDataForVirtualFile(tileFile);

                using (var ms = new MemoryStream(imageData))
                {
                    tile.Bmp = new Bitmap(ms);
                }

                tiles.Add(tile);
            }
            return(tiles);
        }
Exemple #3
0
        private void AddAnyTiledImages(VirtualFolder parentFolder)
        {
            string tileLayoutPattern = @"_\d\d_\d\d\.\w\w\w";
            var    matches           = parentFolder.Files.Where(x => Regex.IsMatch(x.Name, tileLayoutPattern)).ToList();

            if (matches.Count < 1)
            {
                return;
            }

            List <IVirtualFileEntry> tiledImages = new List <IVirtualFileEntry>();
            VirtualFileTiledImage    tiledImage;

            foreach (var match in matches)
            {
                var startOfName = Regex.Split(match.Name, tileLayoutPattern)[0];

                if (tiledImages.Any(x => x.Name == startOfName))
                {
                    // add to existing
                    var existing = tiledImages.FirstOrDefault(x => x.Name == startOfName);
                    tiledImage = existing.FileData as VirtualFileTiledImage;
                }
                else
                {
                    // create a new one
                    tiledImage      = new VirtualFileTiledImage();
                    tiledImage.Type = FileType.Jpg;
                    var file = new VirtualFileEntry(startOfName, tiledImage);
                    tiledImages.Add(file);
                }
                tiledImage.Tiles.Add(match);
            }

            parentFolder.Files.InsertRange(0, tiledImages);
        }
Exemple #4
0
        private byte[] GetImageDataForTiledImage(VirtualFileTiledImage tiledImage)
        {
            var stitcher = new TileImageStitcher(this);

            return(stitcher.GetAssembledTiledImage(tiledImage));
        }