public static void PNGToTb(string image, string pal, string output)
        {
            BinaryReader reader = new BinaryReader(File.OpenRead(output));              //uncompress output if compressed

            reader.BaseStream.Position = 0x04;
            if ((long)(reader.ReadInt32() + 8) == reader.BaseStream.Length)
            {
                reader.Close();
                Comp.uncompr(output);
            }
            else
            {
                reader.Close();
            }

            PaletteBGRS palette = new PaletteBGRS(pal);

            Bitmap       bmp    = new Bitmap(image);
            BinaryWriter writer = new BinaryWriter((Stream) new FileStream(output, FileMode.Open));

            for (int i = 0; i < bmp.Height; i++)
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    writer.Write(palette.GetIndex(bmp.GetPixel(j, i)));
                }
            }

            writer.Flush();
            writer.Close();
        }
        public static void TbToPNG(string image, string pal, string output)
        {
            int         width   = 512;
            int         height  = 448;
            PaletteBGRS palette = new PaletteBGRS(pal);

            BinaryReader reader = new BinaryReader(File.OpenRead(image));
            Bitmap       bmp    = new Bitmap(width, height);

            for (int i = 0; i < bmp.Height; i++)
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    byte index = reader.ReadByte();
                    bmp.SetPixel(j, i, palette.GetColor(index));
                }
            }
            bmp.Save(output, ImageFormat.Png);
            reader.Close();
        }