Exemplo n.º 1
0
 public static NCGR FromFile(string path)
 {
     NCGR ncgr;
     if (File.Exists(path))
         ncgr = new NCGR(File.ReadAllBytes(path));
     else throw new Exception("The specified file does not exist.");
     return ncgr;
 }
Exemplo n.º 2
0
 public static Bitmap GetScreenResource(NCLR nclr, NCGR ncgr, NSCR nscr)
 {
     if (ncgr != null)
     {
         if (nclr != null)
         {
             if (nscr != null)
             {
                 Bitmap b = new Bitmap(nscr.NRCS.ScreenWidth, nscr.NRCS.ScreenHeight);
                 Graphics g = Graphics.FromImage(b);
                 for (ushort ty = 0; ty < b.Height / 8; ty++)
                 {
                     for (ushort tx = 0; tx < b.Width / 8; tx++)
                     {
                         NSCR.NTFS _NTFS = nscr.NRCS.GetTile(tx, ty);
                         try
                         {
                             if (_NTFS.TileNumber > 0)
                             {
                                 byte[] tileData = ncgr.RAHC.GetTile((ushort)(_NTFS.TileNumber - 1));
                                 Color[] palette = nclr.TTLP.GetPalette(_NTFS.PaletteNumber);
                                 for (byte y = 0; y < 8; y++)
                                     for (byte x = 0; x < 8; x++)
                                         g.FillRectangle(new SolidBrush(palette[tileData[x + y * 8]]), new Rectangle(tx * 8 + x, ty * 8 + y, 1, 1));
                             }
                         }
                         catch { }
                     }
                 }
                 return b;
             }
             throw new Exception("NSCR was null");
         }
         throw new Exception("NCLR was null");
     }
     throw new Exception("NCGR was null");
 }