Example #1
0
 internal static BitmapBits[] S3KMapFrameDPLCToBmp(byte[] file, S3KMappings map, DPLC dplc, int startpal, out Point offset)
 {
     byte[] art = ProcessDPLC(file, dplc);
     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(
                     TileToBmp8bpp(art, 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;
 }
 public static Sprite MapDPLCToBmp(byte[] artfile, byte[] mapfile, byte[] dplc, EngineVersion dplcversion, int frame, int startpal)
 {
     BitmapBits[] bmp = null;
     Point off = new Point();
     DPLC dp = new DPLC(dplc, ByteConverter.ToInt16(dplc, frame * 2), dplcversion);
     switch (LevelData.EngineVersion)
     {
         case EngineVersion.S2:
         case EngineVersion.S2NA:
             S2Mappings s2map = new S2Mappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S2MapFrameDPLCToBmp(artfile, s2map, dp, startpal, out off);
             break;
         case EngineVersion.S3K:
         case EngineVersion.SKC:
             S3KMappings s3kmap = new S3KMappings(mapfile, ByteConverter.ToInt16(mapfile, frame * 2));
             bmp = LevelData.S3KMapFrameDPLCToBmp(artfile, s3kmap, dp, 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);
 }
Example #3
0
 internal static byte[] ProcessDPLC(byte[] artfile, DPLC dplc)
 {
     List<byte> result = new List<byte>();
     byte[] tmp;
     for (int i = 0; i < dplc.Count; i++)
     {
         tmp = new byte[dplc[i].TileCount * 0x20];
         Array.Copy(artfile, dplc[i].TileNum * 0x20, tmp, 0, tmp.Length);
         result.AddRange(tmp);
     }
     return result.ToArray();
 }