public static void WritePal(this byte[] data, int destOffset, MPalette pal)
 {
     for (int i = 0; i < pal.ColorCount; i++)
     {
         data.WriteColor(destOffset, pal.GetColorAt(i), i);
     }
 }
 public static void CopyPal(this byte[] data, int srcOffset, MPalette dest, int destIndex = 0)
 {
     for (int i = 0; i < 16; i++)
     {
         dest.SetColorAt(i + destIndex, data.ReadColor(srcOffset, i));
     }
 }
        public static MPalette ReadPal(this byte[] data, int srcOffset)
        {
            var ret = new MPalette(1);

            data.CopyPal(srcOffset, ret);
            return(ret);
        }
        public static MPalette ReadPals(this byte[] data, int num, int offset)
        {
            var ret = new MPalette(num);

            for (int i = 0; i < num; i++)
            {
                data.CopyPal(offset + (i << 5), ret, i << 4);
            }
            return(ret);
        }
        public static void CopyPalette(this Bitmap bmp, MPalette pal, bool transparent)
        {
            ColorPalette cp = bmp.Palette;

            for (int i = 0; i < Math.Min(256, pal.ColorCount); i++)
            {
                cp.Entries[i] = pal.GetColorAt(i);
            }
            for (int i = Math.Min(256, pal.ColorCount); i < 256; i++)
            {
                cp.Entries[i] = Color.Black;
            }

            if (transparent)
            {
                cp.Entries[0] = Color.Transparent;
            }

            bmp.Palette = cp;
        }
 public void SetPalette(MPalette pal)
 {
     palSelector.Palettes = pal;
 }
 public static void WritePal(this byte[] data, MPalette pal)
 {
     data.WritePal(Offset, pal);
     Offset += (pal.Count << 5);
 }