Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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;
        }