예제 #1
0
        public void GetPalette(Rgb565[] palette, int index = 0)
        {
            if (palette == null)
            {
                throw new ArgumentNullException("palette");
            }

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (palette.Length - index < 4)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            var c0 = Rgb0;
            var c1 = Rgb1;

            palette[index + 0] = c0;
            palette[index + 1] = c1;

            if (HasTransparentValues)
            {
                var interp = new Rgb565();

                interp.R = (c0.R + c1.R) / 2;
                interp.G = (c0.G + c1.G) / 2;
                interp.B = (c0.B + c1.B) / 2;

                palette[index + 2] = interp;

                palette[index + 3] = new Rgb565(0);
            }
            else
            {
                var interp = new Rgb565();

                interp.R = (c0.R * 2 + c1.R) / 3;
                interp.G = (c0.G * 2 + c1.G) / 3;
                interp.B = (c0.B * 2 + c1.B) / 3;

                palette[index + 2] = interp;

                interp.R = (c0.R + c1.R * 2) / 3;
                interp.G = (c0.G + c1.G * 2) / 3;
                interp.B = (c0.B + c1.B * 2) / 3;

                palette[index + 3] = interp;
            }
        }
예제 #2
0
 public BC1Block(Rgb565 r0, Rgb565 r1)
 {
     PackedValue = ((ulong)r1.PackedValue << 16) | r0.PackedValue;
 }