Ejemplo n.º 1
0
        public PlayerColorRemap(int[] Ramp, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1);             /* temptemp: this can be expressed better */

            var baseIndex = Ramp[0];
            var RemapRamp = GetRemapRamp(Ramp);

            remapColors = RemapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
                          .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 2
0
        public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1);             /* temptemp: this can be expressed better */

            var baseIndex = GetRemapBase(fmt);
            var ramp      = GetRemapRamp(fmt);

            remapColors = ramp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
                          .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 3
0
        public PlayerColorRemap(int[] Ramp, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1); /* temptemp: this can be expressed better */

            var baseIndex =  Ramp[0];
            var RemapRamp = GetRemapRamp(Ramp);

            remapColors = RemapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
                .ToDictionary(u => u.First, u => u.Second);
        }
        public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1); /* temptemp: this can be expressed better */

            var baseIndex = GetRemapBase(fmt);
            var ramp = GetRemapRamp(fmt);

            remapColors = ramp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
                .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 5
0
        public PlayerColorRemap(ColorRamp c, PaletteFormat fmt)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1); /* temptemp: this can be expressed better */

            var baseIndex = (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80;
            var ramp = (fmt == PaletteFormat.cnc)
                ? new[] { 0, 2, 4, 6, 8, 10, 13, 15, 1, 3, 5, 7, 9, 11, 12, 14 }
                : new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

            remapColors = ramp.Select((x, i) => Pair.New(baseIndex + i, ColorLerp(x / 16f, c1, c2)))
                .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 6
0
        public PlayerColorRemap(PaletteFormat fmt, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1);             /* temptemp: this can be expressed better */

            var baseIndex = (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80;
            var ramp      = (fmt == PaletteFormat.cnc)
                                ? new[] { 0, 2, 4, 6, 8, 10, 13, 15, 1, 3, 5, 7, 9, 11, 12, 14 }
                                : new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

            remapColors = ramp.Select((x, i) => Pair.New(baseIndex + i, ColorLerp(x / 16f, c1, c2)))
                          .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 7
0
        public PlayerColorRemap(int[] Ramp, ColorRamp c)
        {
            var c1 = c.GetColor(0);
            var c2 = c.GetColor(1);             // temptemp: this can be expressed better

            var baseIndex = Ramp[0];
            var RemapRamp = Ramp.Select(r => r - Ramp[0]).ToArray();

            if (Ramp[0] > Ramp[15])             // reversed remapping
            {
                baseIndex = Ramp[15];
                for (int i = 15; i > 0; i--)
                {
                    RemapRamp = Ramp.Select(r => r - Ramp[15]).ToArray();
                }
            }

            remapColors = RemapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))
                          .ToDictionary(u => u.First, u => u.Second);
        }
Ejemplo n.º 8
0
        public Bitmap RenderShp(Palette p, int pos)
        {
            int swidth = 0;
            int sheight = 0;
            byte hk;
            byte s;
            byte l;

            if (oldshp == false)
                {swidth = shp.Width; sheight = shp.Height;}

            if (oldshp == true)
                {swidth = shpold.Width; sheight = shpold.Height;}

            hk = Convert.ToByte(pbColor.BackColor.GetHue()*0.7+1);
            s = Convert.ToByte(pbColor.BackColor.GetSaturation()*255);
            l = Convert.ToByte(pbColor.BackColor.GetBrightness() * 255);

            ColorRamp CRamp = new ColorRamp(hk, s, l, 25);
            if (mnuRemap.Checked)
            {
                p = new Palette(p, new PlayerColorRemap(CRamp, palf));
            }
            CRamp.GetColor(0).ToArgb();
            var bitmap = new Bitmap(swidth, sheight);
            var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            unsafe
            {
                int* q = (int*)data.Scan0.ToPointer();
                var stride2 = data.Stride >> 2;
                for (var i = 0; i < swidth; i++)
                    for (var j = 0; j < sheight; j++)
                    {
                        if (oldshp == false)
                        { var frame = shp[pos]; q[j * stride2 + i] = p.GetColor(frame.Image[i + swidth * j]).ToArgb(); }
                        if (oldshp == true)
                        { var frame = shpold[pos]; q[j * stride2 + i] = p.GetColor(frame.Image[i + swidth * j]).ToArgb(); }

                    }
            }
            bitmap.UnlockBits(data);

            return bitmap;
        }
Ejemplo n.º 9
0
        public Bitmap RenderPNG(Palette p, int pos)
        {
            Bitmap bmp = png.ToBitmap(pos);

            if (mnuRemap.Checked)
            {
                byte hk = Convert.ToByte(pbColor.BackColor.GetHue() * 0.7 + 1);
                byte s = Convert.ToByte(pbColor.BackColor.GetSaturation() * 255);
                byte l = Convert.ToByte(pbColor.BackColor.GetBrightness() * 255);
                ColorRamp CRamp = new ColorRamp(hk, s, l, 25);

                for (int x = 0; x < bmp.Width - 1; x++)
                {
                    for (int y = 0; y < bmp.Height - 1; y++)
                    {
                        Color c = bmp.GetPixel(x, y);
                        c = Color.FromArgb(c.A, CalculateHueChange(c, CRamp.GetColor(0).GetHue(), CRamp.GetColor(0).GetSaturation(), CRamp.GetColor(0).GetBrightness()));
                        bmp.SetPixel(x, y, c);
                    }
                }
            }

            return bmp;
        }