Example #1
0
        private void AssignPalettes()
        {
            hasAssignedPalettes = true;

            sixBitRange  = this.GetEquidistantHexValues(64);
            fiveBitRange = this.GetEquidistantHexValues(32);

            OneBppDefaultPalette     = new Palette(BitDepth.OneBpp);
            TwoBppGrayscalePalette   = new Palette(BitDepth.TwoBpp);
            FourBppGrayscalePalette  = new Palette(BitDepth.FourBpp);
            FourBppWindowsPalette    = new Palette(BitDepth.FourBpp);
            EightBppGrayscalePalette = new Palette(BitDepth.EightBpp);
            EightBppColorPalette     = new Palette(BitDepth.EightBpp);

            // Assign OneBppDefaultPalette
            OneBppDefaultPalette.SetColor(0, Color.Black);
            OneBppDefaultPalette.SetColor(1, Color.White);

            // Assign TwoBppGrayscalePalette
            TwoBppGrayscalePalette.SetColor(0, Color.Black);
            TwoBppGrayscalePalette.SetColor(1, Color.FromArgb(85, 85, 85));
            TwoBppGrayscalePalette.SetColor(2, Color.FromArgb(170, 170, 170));
            TwoBppGrayscalePalette.SetColor(3, Color.White);

            // Assign FourBppGrayscalePalette
            FourBppGrayscalePalette.SetColor(0, Color.Black);
            for (int i = 1; i <= 14; i++)
            {
                FourBppGrayscalePalette.SetColor(i, Color.FromArgb(i * 18, i * 18, i * 18));
            }
            FourBppGrayscalePalette.SetColor(15, Color.White);

            // Assign FourBppWindowsPalette
            int[] reds   = new int[] { 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xC0, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xA7, 0x00, 0xFF };
            int[] greens = new int[] { 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xC0, 0x80, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF };
            int[] blues  = new int[] { 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
            for (int i = 0; i < 16; i++)
            {
                FourBppWindowsPalette.SetColor(i, Color.FromArgb(reds[i], greens[i], blues[i]));
            }

            // Assign EightBppGrayscalePalette
            for (int i = 0; i < 256; i++)
            {
                EightBppGrayscalePalette.SetColor(i, Color.FromArgb(i, i, i));
            }

            // Assign EightBppColorPalette
            var threeBitValues = this.GetEquidistantHexValues(8);
            var twoBitValues   = this.GetEquidistantHexValues(4);

            for (int i = 0; i < 256; i++)
            {
                int red   = (i & 0xE0) >> 5;
                int green = (i & 0x1C) >> 2;
                int blue  = i & 0x03;

                EightBppColorPalette.SetColor(i, Color.FromArgb(threeBitValues[red], threeBitValues[green], twoBitValues[blue]));
            }
        }
Example #2
0
        public Palette Clone()
        {
            Palette clone = new Palette(this.BitDepth);

            for (int i = 0; i < this.colors.Length; i++)
            {
                clone.SetColor(i, this.colors[i]);
            }
            return(clone);
        }
Example #3
0
 public Palette Clone()
 {
     Palette clone = new Palette(this.BitDepth);
     for (int i = 0; i < this.colors.Length; i++)
     {
         clone.SetColor(i, this.colors[i]);
     }
     return clone;
 }
Example #4
0
        private void AssignPalettes()
        {
            hasAssignedPalettes = true;

            sixBitRange = this.GetEquidistantHexValues(64);
            fiveBitRange = this.GetEquidistantHexValues(32);

            OneBppDefaultPalette = new Palette(BitDepth.OneBpp);
            TwoBppGrayscalePalette = new Palette(BitDepth.TwoBpp);
            FourBppGrayscalePalette = new Palette(BitDepth.FourBpp);
            FourBppWindowsPalette = new Palette(BitDepth.FourBpp);
            EightBppGrayscalePalette = new Palette(BitDepth.EightBpp);
            EightBppColorPalette = new Palette(BitDepth.EightBpp);

            // Assign OneBppDefaultPalette
            OneBppDefaultPalette.SetColor(0, Color.Black);
            OneBppDefaultPalette.SetColor(1, Color.White);

            // Assign TwoBppGrayscalePalette
            TwoBppGrayscalePalette.SetColor(0, Color.Black);
            TwoBppGrayscalePalette.SetColor(1, Color.FromArgb(85, 85, 85));
            TwoBppGrayscalePalette.SetColor(2, Color.FromArgb(170, 170, 170));
            TwoBppGrayscalePalette.SetColor(3, Color.White);

            // Assign FourBppGrayscalePalette
            FourBppGrayscalePalette.SetColor(0, Color.Black);
            for (int i = 1; i <= 14; i++)
            {
                FourBppGrayscalePalette.SetColor(i, Color.FromArgb(i * 18, i * 18, i * 18));
            }
            FourBppGrayscalePalette.SetColor(15, Color.White);

            // Assign FourBppWindowsPalette
            int[] reds = new int[] { 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xC0, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xA7, 0x00, 0xFF };
            int[] greens = new int[] { 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xC0, 0x80, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF };
            int[] blues = new int[] { 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
            for (int i = 0; i < 16; i++)
            {
                FourBppWindowsPalette.SetColor(i, Color.FromArgb(reds[i], greens[i], blues[i]));
            }

            // Assign EightBppGrayscalePalette
            for (int i = 0; i < 256; i++)
            {
                EightBppGrayscalePalette.SetColor(i, Color.FromArgb(i, i, i));
            }

            // Assign EightBppColorPalette
            var threeBitValues = this.GetEquidistantHexValues(8);
            var twoBitValues = this.GetEquidistantHexValues(4);
            for (int i = 0; i < 256; i++)
            {
                int red = (i & 0xE0) >> 5;
                int green = (i & 0x1C) >> 2;
                int blue = i & 0x03;

                EightBppColorPalette.SetColor(i, Color.FromArgb(threeBitValues[red], threeBitValues[green], twoBitValues[blue]));
            }
        }