public static Sprite MapToBmp(byte[] artfile, byte[] mapfile, int frame, int startpal) { BitmapBits[] bmp = null; Point off = new Point(); switch (LevelData.EngineVersion) { case EngineVersion.S1: S1Mappings s1map = new S1Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2)); bmp = LevelData.S1MapFrameToBmp(artfile, s1map, startpal, out off); break; case EngineVersion.S2: case EngineVersion.S2NA: S2Mappings s2map = new S2Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2)); bmp = LevelData.S2MapFrameToBmp(artfile, s2map, startpal, out off); break; case EngineVersion.S3K: case EngineVersion.SKC: S3KMappings s3kmap = new S3KMappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2)); bmp = LevelData.S3KMapFrameToBmp(artfile, s3kmap, startpal, out off); break; } BitmapBits Image = new BitmapBits(bmp[0].Width, bmp[0].Height); Image.DrawBitmapComposited(bmp[0], Point.Empty); Image.DrawBitmapComposited(bmp[1], Point.Empty); return new Sprite(Image, off); }
internal static BitmapBits[] S2MapFrameToBmp(byte[] file, S2Mappings map, int startpal, out Point offset) { int left = 0; int right = 0; int top = 0; int bottom = 0; for (int i = 0; i < map.TileCount; i++) { left = Math.Min(map[i].X, left); right = Math.Max(map[i].X + (map[i].Width * 8), right); top = Math.Min(map[i].Y, top); bottom = Math.Max(map[i].Y + (map[i].Height * 8), bottom); } offset = new Point(left, top); BitmapBits[] bmp = new BitmapBits[] { new BitmapBits(right - left, bottom - top), new BitmapBits(right - left, bottom - top) }; for (int i = map.TileCount - 1; i >= 0; i--) { BitmapBits pcbmp = new BitmapBits(map[i].Width * 8, map[i].Height * 8); int ti = 0; int pr = map[i].Tile.Priority ? 1 : 0; for (int x = 0; x < map[i].Width; x++) { for (int y = 0; y < map[i].Height; y++) { pcbmp.DrawBitmapComposited( ObjectHelper.TileToBmp8bpp(file, map[i].Tile.Tile + ti, (map[i].Tile.Palette + startpal) & 3), new Point(x * 8, y * 8)); ti++; } } pcbmp.Flip(map[i].Tile.XFlip, map[i].Tile.YFlip); bmp[pr].DrawBitmapComposited(pcbmp, new Point(map[i].X - left, map[i].Y - top)); } return bmp; }