public static Vsp24 FromVsp8(Vsp8 src) { Vsp24 v24 = new Vsp24(); foreach (Vsp8Tile v8t in src.Tiles) { int[] data = new int[256]; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { if (v8t.Pixels[y * 16 + x] > 0) { data[y * 16 + x] = v8t.parent.Palette[v8t.Pixels[y * 16 + x]].IntColor; } else { unchecked { data[y * 16 + x] = ((int)0xFFFF00FF); } } } } Vsp24Tile v24t = new Vsp24Tile(v24, new pr2.BufferImage(16, 16, data)); v24.Tiles.Add(v24t); } v24.FileOnDisk = src.FileOnDisk; v24.Animations = src.Animations; return(v24); }
public static Vsp24 FromVsp8(Vsp8 src) { Vsp24 v24 = new Vsp24(); foreach (Vsp8Tile v8t in src.Tiles) { int[] data = new int[256]; for (int y = 0; y < Global.TILE_SIZE; y++) { for (int x = 0; x < Global.TILE_SIZE; x++) { if (v8t.Pixels[y * Global.TILE_SIZE + x] > 0) { data[y * Global.TILE_SIZE + x] = v8t.parent.Palette[v8t.Pixels[y * Global.TILE_SIZE + x]].IntColor; } else { unchecked { data[y * Global.TILE_SIZE + x] = ((int)0xFFFF00FF); } } } } Vsp24Tile v24t = new Vsp24Tile(v24, new pr2.BufferImage(Global.TILE_SIZE, Global.TILE_SIZE, data)); v24.Tiles.Add(v24t); } v24.FileOnDisk = src.FileOnDisk; v24.Animations = src.Animations; return v24; }
public Vsp8Tile(Vsp8 Parent, byte[] data) { Pixels = data; parent = Parent; }
public static Vsp24 ReadVsp8(FileInfo fi) { if (!fi.Exists) return null; FileStream fs = fi.OpenRead(); BinaryReader br = new BinaryReader(fs); Vsp8 vsp = new Vsp8(); vsp.FileOnDisk = fi; ushort version = br.ReadUInt16(); byte[] pal = br.ReadBytes(768); ushort tilecount = br.ReadUInt16(); for (int i = 0; i < 256; i++) { vsp.Palette[i] = new Vsp8PaletteEntry(); vsp.Palette[i].r = pal[i * 3]; vsp.Palette[i].g = pal[i * 3 + 1]; vsp.Palette[i].b = pal[i * 3 + 2]; } byte[] tiles; if (version == 2) { tiles = br.ReadBytes(tilecount * 256); } else { // tile data is rle compressed int compressedlength = br.ReadInt32(); tiles = DecompressData8(br.ReadBytes(compressedlength)); } byte[] animations = br.ReadBytes(800); br.Close(); MemoryStream ms; ms = new MemoryStream(tiles); br = new BinaryReader(ms); for (int i = 0; i < tilecount; i++) { Vsp8Tile vt = new Vsp8Tile(vsp, br.ReadBytes(256)); vt.doAvg(); vsp.Tiles.Add(vt); } br.Close(); ms = new MemoryStream(animations); br = new BinaryReader(ms); for (int i = 0; i < 100; i++) { VspAnimation va = new VspAnimation(); va.Start = (int)br.ReadUInt16(); va.End = (int)br.ReadUInt16(); va.Delay = (int)br.ReadUInt16(); va.Mode = (int)br.ReadUInt16(); va.ID = i; vsp.Animations.Add(va); } br.Close(); return Vsp24.FromVsp8(vsp); }