public Bitmap AsBitmap(NesColorMapping colorMapping) { var bitmap = new Bitmap(PIXEL_WIDTH, PIXEL_HEIGHT); var graphics = Graphics.FromImage(bitmap); for (var tileIndex = 0; tileIndex < UNMIRRORED_TILES_COUNT; tileIndex++) { var tile = GetTile(tileIndex); graphics.DrawImage( tile.AsBitmap(colorMapping), new Point(tileIndex * Tile32.PIXEL_WIDTH + Shift * SHIFT_UNIT, 0) ); graphics.DrawImage( tile.GetMirror().AsBitmap(colorMapping), new Point((TILES_COUNT - 1 - tileIndex) * Tile32.PIXEL_WIDTH + Shift * SHIFT_UNIT, 0) ); // account for tiles that wrap around to the left side graphics.DrawImage( tile.AsBitmap(colorMapping), new Point(tileIndex * Tile32.PIXEL_WIDTH + Shift * SHIFT_UNIT - PIXEL_WIDTH, 0) ); graphics.DrawImage( tile.GetMirror().AsBitmap(colorMapping), new Point((TILES_COUNT - 1 - tileIndex) * Tile32.PIXEL_WIDTH + Shift * SHIFT_UNIT - PIXEL_WIDTH, 0) ); } return(bitmap); }
public static void Main(string[] args) { if (args.Length < 1) { Console.Error.WriteLine("Missing level ID argument"); return; } if (!int.TryParse(args[0], out int levelId) || levelId < 0 || levelId > 12) { Console.Error.WriteLine("Invalid level ID given"); return; } Console.WriteLine("Parsing level data"); var rom = GameRom.FromFile("Micro Mages.nes"); var colorMapping = NesColorMapping.FromFile("ntscpalette.pal"); var level = new LevelDataParser().Run(rom, levelId); Directory.CreateDirectory(OUTPUT_DIRECTORY); Console.WriteLine("Saving level image data"); SaveLevel(OUTPUT_DIRECTORY + "level.bmp", level, colorMapping); Console.WriteLine("Saving tile image data"); SaveAllTiles(level, colorMapping); Console.WriteLine("Completed"); Console.ReadKey(); return; }
public Bitmap AsBitmap(NesPalette palette, NesColorMapping colorMapping, bool alpha = false) { var bitmap = new Bitmap(PIXEL_WIDTH, PIXEL_HEIGHT); for (int y = 0; y < PIXEL_HEIGHT; y++) { for (int x = 0; x < PIXEL_WIDTH; x++) { Color color; switch (Pattern[y][x]) { case 0: default: color = alpha ? Color.Transparent : palette.BgColor.AsArgbColor(colorMapping); break; case 1: color = palette.Color1.AsArgbColor(colorMapping); break; case 2: color = palette.Color2.AsArgbColor(colorMapping); break; case 3: color = palette.Color3.AsArgbColor(colorMapping); break; } bitmap.SetPixel(x, y, color); } } return(bitmap); }
private static void SaveAllTiles(Level level, NesColorMapping colorMapping) { SaveLevelSegments(level.Tile8s, OUTPUT_DIRECTORY + "tile8s.bmp", colorMapping, 8, 8); SaveLevelSegments(level.Tile16s, OUTPUT_DIRECTORY + "tile16s.bmp", colorMapping, 16, 16); SaveLevelSegments(level.Tile32s, OUTPUT_DIRECTORY + "tile32s.bmp", colorMapping, 32, 32); SaveLevelSegments(level.Tile32s.Select(t => t.GetMirror()), OUTPUT_DIRECTORY + "tile32mirrors.bmp", colorMapping, 32, 32); SaveLevelSegments(level.SpriteTiles, OUTPUT_DIRECTORY + "spritetiles.bmp", colorMapping, 8, 8); SaveLevelSegments(level.GameObjects, OUTPUT_DIRECTORY + "gameobjects.bmp", colorMapping, 64, 64); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { var bitmap = AsBitmapWithoutEnemies(colorMapping); var graphics = Graphics.FromImage(bitmap); foreach (var levelObject in LevelObjects) { graphics.DrawImage(levelObject.AsBitmap(colorMapping), new Point(levelObject.TileX * 8 + levelObject.GameObject.PixelOffset.X, levelObject.TileY * 8 + levelObject.GameObject.PixelOffset.Y)); } return(bitmap); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { var bitmap = new Bitmap(PIXEL_WIDTH, PIXEL_HEIGHT); var graphics = Graphics.FromImage(bitmap); graphics.DrawImage(TopLeftTile.AsBitmap(Palette, colorMapping), new Point(0, 0)); graphics.DrawImage(TopRightTile.AsBitmap(Palette, colorMapping), new Point(PIXEL_WIDTH / 2, 0)); graphics.DrawImage(BottomLeftTile.AsBitmap(Palette, colorMapping), new Point(0, PIXEL_HEIGHT / 2)); graphics.DrawImage(BottomRightTile.AsBitmap(Palette, colorMapping), new Point(PIXEL_WIDTH / 2, PIXEL_HEIGHT / 2)); return(bitmap); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { var bitmap = new Bitmap(PixelWidth, PixelHeight); var graphics = Graphics.FromImage(bitmap); foreach (var tileData in TilesData) { graphics.DrawImage(tileData.AsBitmap(Palette, colorMapping), new Point(tileData.PixelOffset.X, tileData.PixelOffset.Y)); } return(bitmap); }
public Bitmap AsBitmapWithoutEnemies(NesColorMapping colorMapping) { var bitmap = new Bitmap(PIXEL_WIDTH, PIXEL_HEIGHT); var graphics = Graphics.FromImage(bitmap); for (var rowIndex = 0; rowIndex < ROWS_COUNT; rowIndex++) { var row = Tile32Rows[rowIndex]; graphics.DrawImage(row.AsBitmap(colorMapping), new Point(0, Tile32Row.PIXEL_HEIGHT * (Tile32Rows.Count - 1 - rowIndex))); } return(bitmap); }
public Bitmap AsBitmap(NesPalette palette, NesColorMapping colorMapping) { var bitmap = Level.SpriteTiles[Id].AsBitmap(palette, colorMapping, true); if (FlipX && FlipY) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipXY); } else if (FlipX) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); } else if (FlipY) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); } return(bitmap); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { var bitmap = Level.GameObjects[GameObjectId].AsBitmap(colorMapping); if (FlipX && FlipY) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipXY); } else if (FlipX) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); } else if (FlipY) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); } return(bitmap); }
private static void SaveLevelSegments <T>(IEnumerable <T> elements, string filepath, NesColorMapping colorMapping, int elementWidth, int elementHeight) where T : ILevelSegment { var bitmap = new Bitmap(elementWidth * 16, elementHeight * 16); var graphics = Graphics.FromImage(bitmap); foreach (var e in elements.Where(e => e != null)) { graphics.DrawImage(e.AsBitmap(colorMapping), new Point((e.Id % 16) * elementWidth, (e.Id / 16) * elementHeight)); } bitmap.Save(filepath); }
private static void SaveLevel(string filepath, Level level, NesColorMapping colorMapping) { level.AsBitmap(colorMapping).Save(filepath); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { return(AsBitmap(Level.SpritePalettes.FirstOrDefault(), colorMapping)); }
public Bitmap AsBitmap(NesColorMapping colorMapping) { return(AsBitmap(Level.Tile16Palettes.First(), colorMapping)); }