Пример #1
0
        public static void DES2(IPixelWorker <sPixel> worker)
        {
            var n  = worker.SourceP0M1();
            var w  = worker.SourceM1P0();
            var c  = worker.SourceP0P0();
            var e  = worker.SourceP1P0();
            var s  = worker.SourceP0P1();
            var se = worker.SourceP1P1();

            var p0 = w.IsLike(n) && n.IsNotLike(e) && w.IsNotLike(s) ? w : c;
            var p1 = n.IsLike(e) && n.IsNotLike(w) && e.IsNotLike(s) ? e : c;
            var p2 = w.IsLike(s) && w.IsNotLike(n) && s.IsNotLike(e) ? w : c;
            var p3 = s.IsLike(e) && w.IsNotLike(s) && n.IsNotLike(e) ? e : c;

            var cx  = c;
            var ce  = sPixel.Interpolate(c, e, 3, 1);
            var cs  = sPixel.Interpolate(c, s, 3, 1);
            var cse = sPixel.Interpolate(c, se, 3, 1);


            var d1 = sPixel.Interpolate(p0, cx, 3, 1);
            var d2 = sPixel.Interpolate(p1, ce, 3, 1);
            var d3 = sPixel.Interpolate(p2, cs, 3, 1);
            var d4 = sPixel.Interpolate(p3, cse, 3, 1);

            worker.TargetP0P0(d1);
            worker.TargetP1P0(d2);
            worker.TargetP0P1(d3);
            worker.TargetP1P1(d4);
        }
Пример #2
0
        /// <summary>
        /// MAME's AdvInterp2x, very similar to Scale2x but uses interpolation, modified by Hawkynt to support thresholds
        /// </summary>
        public static void AdvInterp2x(IPixelWorker <sPixel> worker)
        {
            var    c1 = worker.SourceP0M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c7 = worker.SourceP0P1();
            sPixel e01, e10, e11;
            var    e00 = e01 = e10 = e11 = c4;

            if (c1.IsNotLike(c7) && c3.IsNotLike(c5))
            {
                if (c3.IsLike(c1))
                {
                    e00 = sPixel.Interpolate(sPixel.Interpolate(c1, c3), c4, 5, 3);
                }
                if (c5.IsLike(c1))
                {
                    e01 = sPixel.Interpolate(sPixel.Interpolate(c1, c5), c4, 5, 3);
                }
                if (c3.IsLike(c7))
                {
                    e10 = sPixel.Interpolate(sPixel.Interpolate(c7, c3), c4, 5, 3);
                }
                if (c5.IsLike(c7))
                {
                    e11 = sPixel.Interpolate(sPixel.Interpolate(c7, c5), c4, 5, 3);
                }
            }
            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #3
0
        /// <summary>
        /// another bad one a made for MS-Dos in 1998
        /// </summary>
        public static void Tv3x(IPixelWorker <sPixel> worker)
        {
            var pixel = worker.SourceP0P0();

            worker.TargetP0P0(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
            worker.TargetP1P0(new sPixel(0, pixel.Green, 0, pixel.Alpha));
            worker.TargetP2P0(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            if ((worker.SourceX() & 1) == 0)
            {
                worker.TargetP0P1(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
                if (worker.SourceY() > 0)
                {
                    worker.TargetP1M1(new sPixel(0, pixel.Green, 0, pixel.Alpha));
                }
                worker.TargetP2P1(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            }
            else
            {
                if (worker.SourceY() > 0)
                {
                    worker.TargetP0M1(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
                }
                worker.TargetP1P1(new sPixel(0, pixel.Green, 0, pixel.Alpha));
                if (worker.SourceY() > 0)
                {
                    worker.TargetP2M1(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
                }
            }
        }
Пример #4
0
        public static void DoUltra2XScl(IPixelWorker <sPixel> worker)
        {
            var n = worker.SourceP0M1();
            var w = worker.SourceM1P0();
            var c = worker.SourceP0P0();
            var e = worker.SourceP1P0();
            var s = worker.SourceP0P1();

            var cx = c;
            var wx = w;
            var ex = e;
            var cw = _Mixpal(c, w);
            var ce = _Mixpal(c, e);

            var p0 = w.IsLike(n) && n.IsNotLike(e) && w.IsNotLike(s) ? wx : cw;
            var p1 = n.IsLike(e) && n.IsNotLike(w) && e.IsNotLike(s) ? ex : ce;
            var p2 = w.IsLike(s) && w.IsNotLike(n) && s.IsNotLike(e) ? wx : cw;
            var p3 = s.IsLike(e) && w.IsNotLike(s) && n.IsNotLike(e) ? ex : ce;

            p0 = _Unmix(p0, cx);
            p1 = _Unmix(p1, cx);
            p2 = _Unmix(p2, cx);
            p3 = _Unmix(p3, cx);

            worker.TargetP0P0(p0);
            worker.TargetP1P0(p1);
            worker.TargetP0P1(p2);
            worker.TargetP1P1(p3);
        }
Пример #5
0
        /// <summary>
        /// MAME's RGB 2x
        /// </summary>
        public static void Rgb2x(IPixelWorker <sPixel> worker)
        {
            var pixel = worker.SourceP0P0();

            worker.TargetP0P0(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
            worker.TargetP1P0(new sPixel(0, pixel.Green, 0, pixel.Alpha));
            worker.TargetP0P1(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            worker.TargetP1P1(pixel);
        }
Пример #6
0
        /// <summary>
        /// Vertical scanlines
        /// </summary>
        public static void VerticalScanlines(IPixelWorker <sPixel> worker, float grayFactor)
        {
            var pixel = worker.SourceP0P0();

            worker.TargetP0P0(pixel);
            var factor = grayFactor / 100f + 1f;

            worker.TargetP1P0(pixel * factor);
        }
Пример #7
0
        /// <summary>
        /// just a bad old-school TV effect
        /// </summary>
        public static void Tv2x(IPixelWorker <sPixel> worker)
        {
            var pixel     = worker.SourceP0P0();
            var luminance = pixel.Luminance;

            worker.TargetP0P0(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
            worker.TargetP1P0(new sPixel(0, pixel.Green, 0, pixel.Alpha));
            worker.TargetP0P1(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            worker.TargetP1P1(sPixel.FromGrey(luminance, pixel.Alpha));
        }
Пример #8
0
        /// <summary>
        /// MAME's TV effect in 2x
        /// </summary>
        public static void Tv2x(IPixelWorker <sPixel> worker)
        {
            var pixel    = worker.SourceP0P0();
            var subPixel = pixel * _gamma58;

            worker.TargetP0P0(pixel);
            worker.TargetP1P0(pixel);
            worker.TargetP0P1(subPixel);
            worker.TargetP1P1(subPixel);
        }
Пример #9
0
        /// <summary>
        /// This is the XBR4x by Hyllian (see http://board.byuu.org/viewtopic.php?f=10&t=2248)
        /// </summary>
        public static void Xbr4X(IPixelWorker <sPixel> worker, bool allowAlphaBlending)
        {
            Contract.Assume(worker != null);
            var a1 = worker.SourceM1M2();
            var b1 = worker.SourceP0M2();
            var c1 = worker.SourceP1M2();

            var a0 = worker.SourceM2M1();
            var pa = worker.SourceM1M1();
            var pb = worker.SourceP0M1();
            var pc = worker.SourceP1M1();
            var c4 = worker.SourceP2M1();

            var d0 = worker.SourceM2P0();
            var pd = worker.SourceM1P0();
            var pe = worker.SourceP0P0();
            var pf = worker.SourceP1P0();
            var f4 = worker.SourceP2P0();

            var g0 = worker.SourceM2P1();
            var pg = worker.SourceM1P1();
            var ph = worker.SourceP0P1();
            var pi = worker.SourceP1P1();
            var i4 = worker.SourceP2P1();

            var g5 = worker.SourceM1P2();
            var h5 = worker.SourceP0P2();
            var i5 = worker.SourceP1P2();

            sPixel e1, e2, e3, e4, e5, e6, e7, e8, e9, ea, eb, ec, ed, ee, ef;
            var    e0 = e1 = e2 = e3 = e4 = e5 = e6 = e7 = e8 = e9 = ea = eb = ec = ed = ee = ef = pe;

            _Kernel4Xv2(pe, pi, ph, pf, pg, pc, pd, pb, f4, i4, h5, i5, ref ef, ref ee, ref eb, ref e3, ref e7, ref ea, ref ed, ref ec, allowAlphaBlending);
            _Kernel4Xv2(pe, pc, pf, pb, pi, pa, ph, pd, b1, c1, f4, c4, ref e3, ref e7, ref e2, ref e0, ref e1, ref e6, ref eb, ref ef, allowAlphaBlending);
            _Kernel4Xv2(pe, pa, pb, pd, pc, pg, pf, ph, d0, a0, b1, a1, ref e0, ref e1, ref e4, ref ec, ref e8, ref e5, ref e2, ref e3, allowAlphaBlending);
            _Kernel4Xv2(pe, pg, pd, ph, pa, pi, pb, pf, h5, g5, d0, g0, ref ec, ref e8, ref ed, ref ef, ref ee, ref e9, ref e4, ref e0, allowAlphaBlending);

            worker.TargetP0P0(e0);
            worker.TargetP1P0(e1);
            worker.TargetP2P0(e2);
            worker.TargetP3P0(e3);
            worker.TargetP0P1(e4);
            worker.TargetP1P1(e5);
            worker.TargetP2P1(e6);
            worker.TargetP3P1(e7);
            worker.TargetP0P2(e8);
            worker.TargetP1P2(e9);
            worker.TargetP2P2(ea);
            worker.TargetP3P2(eb);
            worker.TargetP0P3(ec);
            worker.TargetP1P3(ed);
            worker.TargetP2P3(ee);
            worker.TargetP3P3(ef);
        }
Пример #10
0
        /// <summary>
        /// MAME's TV effect 3x
        /// </summary>
        public static void Tv3x(IPixelWorker <sPixel> worker)
        {
            var pixel     = worker.SourceP0P0();
            var subPixel  = pixel * _gamma58;
            var subPixel2 = pixel * _gamma516;

            worker.TargetP0P0(pixel);
            worker.TargetP1P0(pixel);
            worker.TargetP2P0(pixel);
            worker.TargetP0P1(subPixel);
            worker.TargetP1P1(subPixel);
            worker.TargetP2P1(subPixel);
            worker.TargetP0P2(subPixel2);
            worker.TargetP1P2(subPixel2);
            worker.TargetP2P2(subPixel2);
        }
Пример #11
0
        /// <summary>
        /// This is the XBR3x by Hyllian (see http://board.byuu.org/viewtopic.php?f=10&t=2248)
        /// </summary>
        public static void Xbr3X(IPixelWorker <sPixel> worker, bool allowAlphaBlending, bool useOriginalImplementation)
        {
            Contract.Assume(worker != null);
            var a1 = worker.SourceM1M2();
            var b1 = worker.SourceP0M2();
            var c1 = worker.SourceP1M2();

            var a0 = worker.SourceM2M1();
            var pa = worker.SourceM1M1();
            var pb = worker.SourceP0M1();
            var pc = worker.SourceP1M1();
            var c4 = worker.SourceP2M1();

            var d0 = worker.SourceM2P0();
            var pd = worker.SourceM1P0();
            var pe = worker.SourceP0P0();
            var pf = worker.SourceP1P0();
            var f4 = worker.SourceP2P0();

            var g0 = worker.SourceM2P1();
            var pg = worker.SourceM1P1();
            var ph = worker.SourceP0P1();
            var pi = worker.SourceP1P1();
            var i4 = worker.SourceP2P1();

            var g5 = worker.SourceM1P2();
            var h5 = worker.SourceP0P2();
            var i5 = worker.SourceP1P2();

            sPixel e1, e2, e3, e4, e5, e6, e7, e8;
            var    e0 = e1 = e2 = e3 = e4 = e5 = e6 = e7 = e8 = pe;

            _Kernel3X(pe, pi, ph, pf, pg, pc, pd, pb, f4, i4, h5, i5, ref e2, ref e5, ref e6, ref e7, ref e8, allowAlphaBlending, useOriginalImplementation);
            _Kernel3X(pe, pc, pf, pb, pi, pa, ph, pd, b1, c1, f4, c4, ref e0, ref e1, ref e8, ref e5, ref e2, allowAlphaBlending, useOriginalImplementation);
            _Kernel3X(pe, pa, pb, pd, pc, pg, pf, ph, d0, a0, b1, a1, ref e6, ref e3, ref e2, ref e1, ref e0, allowAlphaBlending, useOriginalImplementation);
            _Kernel3X(pe, pg, pd, ph, pa, pi, pb, pf, h5, g5, d0, g0, ref e8, ref e7, ref e0, ref e3, ref e6, allowAlphaBlending, useOriginalImplementation);

            worker.TargetP0P0(e0);
            worker.TargetP1P0(e1);
            worker.TargetP2P0(e2);
            worker.TargetP0P1(e3);
            worker.TargetP1P1(e4);
            worker.TargetP2P1(e5);
            worker.TargetP0P2(e6);
            worker.TargetP1P2(e7);
            worker.TargetP2P2(e8);
        }
Пример #12
0
        /// <summary>
        /// Bilinear Plus Original
        /// </summary>
        public static void BilinearPlusOriginal(IPixelWorker <sPixel> worker)
        {
            var c00 = worker.SourceP0P0();
            var c01 = worker.SourceP1P0();
            var c10 = worker.SourceP0P1();
            var c11 = worker.SourceP1P1();

            var e00 = sPixel.Interpolate(c00, c01, c10, 5, 2, 1);
            var e01 = sPixel.Interpolate(c00, c01);
            var e10 = sPixel.Interpolate(c00, c10);
            var e11 = sPixel.Interpolate(c00, c01, c10, c11);

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #13
0
        /// <summary>
        /// DES filters from FNES
        /// </summary>
        public static void DES(IPixelWorker <sPixel> worker)
        {
            var n = worker.SourceP0M1();
            var w = worker.SourceM1P0();
            var c = worker.SourceP0P0();
            var e = worker.SourceP1P0();
            var s = worker.SourceP0P1();


            var p0 = w.IsLike(n) && n.IsNotLike(e) && w.IsNotLike(s) ? w : c;
            var p1 = n.IsLike(e) && n.IsNotLike(w) && e.IsNotLike(s) ? e : c;
            var p2 = w.IsLike(s) && w.IsNotLike(n) && s.IsNotLike(e) ? w : c;
            var p3 = s.IsLike(e) && w.IsNotLike(s) && n.IsNotLike(e) ? e : c;

            var d = sPixel.Interpolate(p0, p1, p2, p3);

            worker.TargetP0P0(d);
        }
Пример #14
0
        /// <summary>
        /// FNES' 2xSCL
        /// </summary>
        /// <param name="worker">The worker.</param>
        public static void Do2XScl(IPixelWorker <sPixel> worker)
        {
            var n = worker.SourceP0M1();
            var w = worker.SourceM1P0();
            var c = worker.SourceP0P0();
            var e = worker.SourceP1P0();
            var s = worker.SourceP0P1();

            var p0 = w.IsLike(n) && n.IsNotLike(e) && w.IsNotLike(s) ? w : c;
            var p1 = n.IsLike(e) && n.IsNotLike(w) && e.IsNotLike(s) ? e : c;
            var p2 = w.IsLike(s) && w.IsNotLike(n) && s.IsNotLike(e) ? w : c;
            var p3 = s.IsLike(e) && w.IsNotLike(s) && n.IsNotLike(e) ? e : c;

            worker.TargetP0P0(p0);
            worker.TargetP1P0(p1);
            worker.TargetP0P1(p2);
            worker.TargetP1P1(p3);
        }
Пример #15
0
        /// <summary>
        /// another one that takes into account that normal eagle means that 3 surroundings should be equal
        /// looks ugly sometimes depends heavily on source image
        /// </summary>
        public static void Eagle3xB(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e02, e10, e12, e20, e21, e22;
            var    e00 = e01 = e02 = e10 = e12 = e20 = e21 = e22 = c4;

            if (c0.IsLike(c1) && c0.IsLike(c3))
            {
                e00 = sPixel.Interpolate(c0, c1, c3);
            }

            if (c2.IsLike(c1) && c2.IsLike(c5))
            {
                e02 = sPixel.Interpolate(c2, c1, c5);
            }

            if (c6.IsLike(c3) && c6.IsLike(c7))
            {
                e20 = sPixel.Interpolate(c6, c3, c7);
            }

            if (c8.IsLike(c5) && c8.IsLike(c7))
            {
                e22 = sPixel.Interpolate(c8, c5, c7);
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP2P0(e02);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(c4);
            worker.TargetP2P1(e12);
            worker.TargetP0P2(e20);
            worker.TargetP1P2(e21);
            worker.TargetP2P2(e22);
        }
Пример #16
0
        /// <summary>
        /// Bilinear Plus
        /// </summary>
        public static void BilinearPlus(IPixelWorker <sPixel> worker)
        {
            var c00 = worker.SourceP0P0();
            var c01 = worker.SourceP1P0();
            var c10 = worker.SourceP0P1();
            var c11 = worker.SourceP1P1();

            const float gamma = 14f / 16f;

            var e00 = sPixel.Interpolate(c00, c01, c10, 10, 2, 2) * gamma;
            var e01 = sPixel.Interpolate(c00, c01);
            var e10 = sPixel.Interpolate(c00, c10);
            var e11 = sPixel.Interpolate(c00, c01, c10, c11);

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #17
0
        /// <summary>
        /// This is the XBR2x by Hyllian (see http://board.byuu.org/viewtopic.php?f=10&t=2248)
        /// </summary>
        public static void Xbr2X(IPixelWorker <sPixel> worker, bool allowAlphaBlending)
        {
            Contract.Assume(worker != null);
            var a1 = worker.SourceM1M2();
            var b1 = worker.SourceP0M2();
            var c1 = worker.SourceP1M2();

            var a0 = worker.SourceM2M1();
            var pa = worker.SourceM1M1();
            var pb = worker.SourceP0M1();
            var pc = worker.SourceP1M1();
            var c4 = worker.SourceP2M1();

            var d0 = worker.SourceM2P0();
            var pd = worker.SourceM1P0();
            var pe = worker.SourceP0P0();
            var pf = worker.SourceP1P0();
            var f4 = worker.SourceP2P0();

            var g0 = worker.SourceM2P1();
            var pg = worker.SourceM1P1();
            var ph = worker.SourceP0P1();
            var pi = worker.SourceP1P1();
            var i4 = worker.SourceP2P1();

            var g5 = worker.SourceM1P2();
            var h5 = worker.SourceP0P2();
            var i5 = worker.SourceP1P2();

            sPixel e1, e2, e3;
            var    e0 = e1 = e2 = e3 = pe;

            _Kernel2Xv5(pe, pi, ph, pf, pg, pc, pd, pb, f4, i4, h5, i5, ref e1, ref e2, ref e3, allowAlphaBlending);
            _Kernel2Xv5(pe, pc, pf, pb, pi, pa, ph, pd, b1, c1, f4, c4, ref e0, ref e3, ref e1, allowAlphaBlending);
            _Kernel2Xv5(pe, pa, pb, pd, pc, pg, pf, ph, d0, a0, b1, a1, ref e2, ref e1, ref e0, allowAlphaBlending);
            _Kernel2Xv5(pe, pg, pd, ph, pa, pi, pb, pf, h5, g5, d0, g0, ref e3, ref e0, ref e2, allowAlphaBlending);

            worker.TargetP0P0(e0);
            worker.TargetP1P0(e1);
            worker.TargetP0P1(e2);
            worker.TargetP1P1(e3);
        }
Пример #18
0
        /// <summary>
        /// good old Eagle Engine modified by Hawkynt to support thresholds
        /// </summary>
        public static void Eagle2x(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e10, e11;
            var    e00 = e01 = e10 = e11 = c4;

            if (c1.IsLike(c0) && c1.IsLike(c3))
            {
                e00 = sPixel.Interpolate(c1, c0, c3);
            }

            if (c2.IsLike(c1) && c2.IsLike(c5))
            {
                e01 = sPixel.Interpolate(c2, c1, c5);
            }

            if (c6.IsLike(c3) && c6.IsLike(c7))
            {
                e10 = sPixel.Interpolate(c6, c3, c7);
            }

            if (c7.IsLike(c5) && c7.IsLike(c8))
            {
                e11 = sPixel.Interpolate(c7, c5, c8);
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #19
0
        /// <summary>
        /// Christoph Feck's ([email protected]) Reverse Anti-Alias filter
        /// TODO: make mathutils and join clamp, min and max with the ones from spixel
        /// </summary>
        /// <param name="worker">The worker.</param>
        public static void Process(IPixelWorker <sPixel> worker)
        {
            var b1 = worker.SourceP0M2();
            var b  = worker.SourceP0M1();
            var d  = worker.SourceM1P0();
            var e  = worker.SourceP0P0();
            var f  = worker.SourceP1P0();
            var h  = worker.SourceP0P1();
            var h5 = worker.SourceP0P2();
            var d0 = worker.SourceM2P0();
            var f4 = worker.SourceP2P0();

            var redPart   = _ReverseAntiAlias(b1.Red, b.Red, d.Red, e.Red, f.Red, h.Red, h5.Red, d0.Red, f4.Red);
            var greenPart = _ReverseAntiAlias(b1.Green, b.Green, d.Green, e.Green, f.Green, h.Green, h5.Green, d0.Green, f4.Green);
            var bluePart  = _ReverseAntiAlias(b1.Blue, b.Blue, d.Blue, e.Blue, f.Blue, h.Blue, h5.Blue, d0.Blue, f4.Blue);
            var alphaPart = _ReverseAntiAlias(b1.Alpha, b.Alpha, d.Alpha, e.Alpha, f.Alpha, h.Alpha, h5.Alpha, d0.Alpha, f4.Alpha);

            worker.TargetP0P0(sPixel.FromRGBA(redPart.Item1, greenPart.Item1, bluePart.Item1, alphaPart.Item1));
            worker.TargetP1P0(sPixel.FromRGBA(redPart.Item2, greenPart.Item2, bluePart.Item2, alphaPart.Item2));
            worker.TargetP0P1(sPixel.FromRGBA(redPart.Item3, greenPart.Item3, bluePart.Item3, alphaPart.Item3));
            worker.TargetP1P1(sPixel.FromRGBA(redPart.Item4, greenPart.Item4, bluePart.Item4, alphaPart.Item4));
        }
Пример #20
0
        /// <summary>
        /// SNES9x's EPXC modified by Hawkynt to support thresholds
        /// </summary>
        public static void EpxC(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e10, e11;
            var    e00 = e01 = e10 = e11 = c4;

            if (c3.IsNotLike(c5) && c7.IsNotLike(c1))
            {
                var neq40 = c4.IsNotLike(c0);
                var neq41 = c4.IsNotLike(c1);
                var neq42 = c4.IsNotLike(c2);
                var neq43 = c4.IsNotLike(c3);
                var neq45 = c4.IsNotLike(c5);
                var neq46 = c4.IsNotLike(c6);
                var neq47 = c4.IsNotLike(c7);
                var neq48 = c4.IsNotLike(c8);

                var eq13 = c1.IsLike(c3) && (neq40 || neq48 || c1.IsNotLike(c2) || c3.IsNotLike(c6));
                var eq37 = c3.IsLike(c7) && (neq46 || neq42 || c3.IsNotLike(c0) || c7.IsNotLike(c8));
                var eq75 = c7.IsLike(c5) && (neq48 || neq40 || c7.IsNotLike(c6) || c5.IsNotLike(c2));
                var eq51 = c5.IsLike(c1) && (neq42 || neq46 || c5.IsNotLike(c8) || c1.IsNotLike(c0));
                if (
                    !neq40 ||
                    !neq41 ||
                    !neq42 ||
                    !neq43 ||
                    !neq45 ||
                    !neq46 ||
                    !neq47 ||
                    !neq48
                    )
                {
                    sPixel c3A;
                    if (eq13 && neq46 && eq37 && neq40)
                    {
                        c3A = sPixel.Interpolate(c3, c1, c7);
                    }
                    else if (eq13 && neq46)
                    {
                        c3A = sPixel.Interpolate(c3, c1);
                    }
                    else if (eq37 && neq40)
                    {
                        c3A = sPixel.Interpolate(c3, c7);
                    }
                    else
                    {
                        c3A = c4;
                    }

                    sPixel c7B;
                    if (eq37 && neq48 && eq75 && neq46)
                    {
                        c7B = sPixel.Interpolate(c7, c3, c5);
                    }
                    else if (eq37 && neq48)
                    {
                        c7B = sPixel.Interpolate(c7, c3);
                    }
                    else if (eq75 && neq46)
                    {
                        c7B = sPixel.Interpolate(c7, c5);
                    }
                    else
                    {
                        c7B = c4;
                    }

                    sPixel c5C;
                    if (eq75 && neq42 && eq51 && neq48)
                    {
                        c5C = sPixel.Interpolate(c5, c1, c7);
                    }
                    else if (eq75 && neq42)
                    {
                        c5C = sPixel.Interpolate(c5, c7);
                    }
                    else if (eq51 && neq48)
                    {
                        c5C = sPixel.Interpolate(c5, c1);
                    }
                    else
                    {
                        c5C = c4;
                    }

                    sPixel c1D;

                    if (eq51 && neq40 && eq13 && neq42)
                    {
                        c1D = sPixel.Interpolate(c1, c3, c5);
                    }
                    else if (eq51 && neq40)
                    {
                        c1D = sPixel.Interpolate(c1, c5);
                    }
                    else if (eq13 && neq42)
                    {
                        c1D = sPixel.Interpolate(c1, c3);
                    }
                    else
                    {
                        c1D = c4;
                    }

                    if (eq13)
                    {
                        e00 = sPixel.Interpolate(c1, c3);
                    }
                    if (eq51)
                    {
                        e01 = sPixel.Interpolate(c5, c1);
                    }
                    if (eq37)
                    {
                        e10 = sPixel.Interpolate(c3, c7);
                    }
                    if (eq75)
                    {
                        e11 = sPixel.Interpolate(c7, c5);
                    }

                    e00 = sPixel.Interpolate(e00, c1D, c3A, c4, 5, 1, 1, 1);
                    e01 = sPixel.Interpolate(e01, c7B, c5C, c4, 5, 1, 1, 1);
                    e10 = sPixel.Interpolate(e10, c3A, c7B, c4, 5, 1, 1, 1);
                    e11 = sPixel.Interpolate(e11, c5C, c1D, c4, 5, 1, 1, 1);
                }
                else
                {
                    if (eq13)
                    {
                        e00 = sPixel.Interpolate(c1, c3);
                    }
                    if (eq51)
                    {
                        e01 = sPixel.Interpolate(c5, c1);
                    }
                    if (eq37)
                    {
                        e10 = sPixel.Interpolate(c3, c7);
                    }
                    if (eq75)
                    {
                        e11 = sPixel.Interpolate(c7, c5);
                    }

                    e00 = sPixel.Interpolate(c4, e00, 3, 1);
                    e01 = sPixel.Interpolate(c4, e01, 3, 1);
                    e10 = sPixel.Interpolate(c4, e10, 3, 1);
                    e11 = sPixel.Interpolate(c4, e11, 3, 1);
                }
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #21
0
        /// <summary>
        /// Derek Liauw Kie Fa's 2XSaI
        /// </summary>
        public static void SaI2X(IPixelWorker <sPixel> worker)
        {
            var c0 = worker.SourceM1M1();
            var c1 = worker.SourceP0M1();
            var c2 = worker.SourceP1M1();
            var d3 = worker.SourceP2M1();
            var c3 = worker.SourceM1P0();
            var c4 = worker.SourceP0P0();
            var c5 = worker.SourceP1P0();
            var d4 = worker.SourceP2P0();
            var c6 = worker.SourceM1P1();
            var c7 = worker.SourceP0P1();
            var c8 = worker.SourceP1P1();
            var d5 = worker.SourceP2P1();
            var d0 = worker.SourceM1P2();
            var d1 = worker.SourceP0P2();
            var d2 = worker.SourceP1P2();

            sPixel e01, e10, e11;
            var    e00 = e01 = e10 = e11 = c4;

            if (c4.IsLike(c8) && c5.IsNotLike(c7))
            {
                var c48 = sPixel.Interpolate(c4, c8);
                if (c48.IsLike(c1) && c5.IsLike(d5) || c48.IsLike(c7) && c48.IsLike(c2) && c5.IsNotLike(c1) && c5.IsLike(d3))
                {
                    //nothing
                }
                else
                {
                    e01 = sPixel.Interpolate(c48, c5);
                }

                if (c48.IsLike(c3) && c7.IsLike(d2) || c48.IsLike(c5) && c48.IsLike(c6) && c3.IsNotLike(c7) && c7.IsLike(d0))
                {
                    //nothing
                }
                else
                {
                    e10 = sPixel.Interpolate(c48, c7);
                }
            }
            else if (c5.IsLike(c7) && c4.IsNotLike(c8))
            {
                var c57 = sPixel.Interpolate(c5, c7);
                if (c57.IsLike(c2) && c4.IsLike(c6) || c57.IsLike(c1) && c57.IsLike(c8) && c4.IsNotLike(c2) && c4.IsLike(c0))
                {
                    e01 = c57;
                }
                else
                {
                    e01 = sPixel.Interpolate(c4, c57);
                }

                if (c57.IsLike(c6) && c4.IsLike(c2) || c57.IsLike(c3) && c57.IsLike(c8) && c4.IsNotLike(c6) && c4.IsLike(c0))
                {
                    e10 = c57;
                }
                else
                {
                    e10 = sPixel.Interpolate(c4, c57);
                }
                e11 = c57;
            }
            else if (c4.IsLike(c8) && c5.IsLike(c7))
            {
                var c48 = sPixel.Interpolate(c4, c8);
                var c57 = sPixel.Interpolate(c5, c7);
                if (c48.IsNotLike(c57))
                {
                    var conc2D = 0;
                    conc2D += _Conc2D(c48, c57, c3, c1);
                    conc2D -= _Conc2D(c57, c48, d4, c2);
                    conc2D -= _Conc2D(c57, c48, c6, d1);
                    conc2D += _Conc2D(c48, c57, d5, d2);

                    if (conc2D < 0)
                    {
                        e11 = c57;
                    }
                    else if (conc2D == 0)
                    {
                        e11 = sPixel.Interpolate(c48, c57);
                    }
                    e10 = sPixel.Interpolate(c48, c57);
                    e01 = sPixel.Interpolate(c48, c57);
                }
            }
            else
            {
                e11 = sPixel.Interpolate(c4, c5, c7, c8);

                if (c4.IsLike(c7) && c4.IsLike(c2) && c5.IsNotLike(c1) && c5.IsLike(d3))
                {
                    //nothing
                }
                else if (c5.IsLike(c1) && c5.IsLike(c8) && c4.IsNotLike(c2) && c4.IsLike(c0))
                {
                    e01 = sPixel.Interpolate(c5, c1, c8);
                }
                else
                {
                    e01 = sPixel.Interpolate(c4, c5);
                }

                if (c4.IsLike(c5) && c4.IsLike(c6) && c3.IsNotLike(c7) && c7.IsLike(d0))
                {
                    //nothing
                }
                else if (c7.IsLike(c3) && c7.IsLike(c8) && c4.IsNotLike(c6) && c4.IsLike(c0))
                {
                    e10 = sPixel.Interpolate(c7, c3, c8);
                }
                else
                {
                    e10 = sPixel.Interpolate(c4, c7);
                }
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #22
0
        /// <summary>
        /// Andrea Mazzoleni's Scale3X modified by Hawkynt to support thresholds
        /// </summary>
        public static void Scale3x(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e02, e10, e11, e12, e20, e21, e22 = c4;
            var    e00 = e01 = e02 = e10 = e11 = e12 = e20 = e21 = e22 = c4;

            if (c1.IsNotLike(c7) && c3.IsNotLike(c5))
            {
                if (c3.IsLike(c1))
                {
                    e00 = sPixel.Interpolate(c3, c1);
                }
                if (c1.IsLike(c5))
                {
                    e02 = sPixel.Interpolate(c1, c5);
                }
                if (c3.IsLike(c7))
                {
                    e20 = sPixel.Interpolate(c3, c7);
                }
                if (c7.IsLike(c5))
                {
                    e22 = sPixel.Interpolate(c7, c5);
                }

                if (
                    c3.IsLike(c1) && c4.IsNotLike(c2) && c5.IsLike(c1) && c4.IsNotLike(c0)
                    )
                {
                    e01 = sPixel.Interpolate(c1, c3, c5);
                }
                else if (c3.IsLike(c1) && c4.IsNotLike(c2))
                {
                    e01 = sPixel.Interpolate(c3, c1);
                }
                else if (c5.IsLike(c1) && c4.IsNotLike(c0))
                {
                    e01 = sPixel.Interpolate(c5, c1);
                }

                if (
                    c3.IsLike(c1) && c4.IsNotLike(c6) && c3.IsLike(c7) && c4.IsNotLike(c0)
                    )
                {
                    e10 = sPixel.Interpolate(c3, c1, c7);
                }
                else if (c3.IsLike(c1) && c4.IsNotLike(c6))
                {
                    e10 = sPixel.Interpolate(c3, c1);
                }
                else if (c3.IsLike(c7) && c4.IsNotLike(c0))
                {
                    e10 = sPixel.Interpolate(c3, c7);
                }

                if (
                    c5.IsLike(c1) && c4.IsNotLike(c8) && c5.IsLike(c7) && c4.IsNotLike(c2)
                    )
                {
                    e12 = sPixel.Interpolate(c5, c1, c7);
                }
                else if (c5.IsLike(c1) && c4.IsNotLike(c8))
                {
                    e12 = sPixel.Interpolate(c5, c1);
                }
                else if (c5.IsLike(c7) && c4.IsNotLike(c2))
                {
                    e12 = sPixel.Interpolate(c5, c7);
                }

                if (
                    c3.IsLike(c7) && c4.IsNotLike(c8) && c5.IsLike(c7) && c4.IsNotLike(c6)
                    )
                {
                    e21 = sPixel.Interpolate(c7, c3, c5);
                }
                else if (c3.IsLike(c7) && c4.IsNotLike(c8))
                {
                    e21 = sPixel.Interpolate(c3, c7);
                }
                else if (c5.IsLike(c7) && c4.IsNotLike(c6))
                {
                    e21 = sPixel.Interpolate(c5, c7);
                }
            }
            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP2P0(e02);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
            worker.TargetP2P1(e12);
            worker.TargetP0P2(e20);
            worker.TargetP1P2(e21);
            worker.TargetP2P2(e22);
        }
Пример #23
0
        /// <summary>
        /// SNES9x's EPXB modified by Hawkynt to support thresholds
        /// </summary>
        public static void EpxB(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e10, e11;
            var    e00 = e01 = e10 = e11 = c4;

            if (
                c3.IsNotLike(c5) &&
                c1.IsNotLike(c7) && (
                    c4.IsLike(c3) ||
                    c4.IsLike(c7) ||
                    c4.IsLike(c5) ||
                    c4.IsLike(c1) || (
                        c0.IsNotLike(c8) ||
                        c4.IsLike(c6) ||
                        c4.IsLike(c2)
                        ) && (
                        c6.IsNotLike(c2) ||
                        c4.IsLike(c0) ||
                        c4.IsLike(c8)
                        )
                    )
                )
            {
                if (
                    c1.IsLike(c3) && (
                        c4.IsNotLike(c0) ||
                        c4.IsNotLike(c8) ||
                        c1.IsNotLike(c2) ||
                        c3.IsNotLike(c6)
                        )
                    )
                {
                    e00 = sPixel.Interpolate(c1, c3);
                }
                if (
                    c5.IsLike(c1) && (
                        c4.IsNotLike(c2) ||
                        c4.IsNotLike(c6) ||
                        c5.IsNotLike(c8) ||
                        c1.IsNotLike(c0)
                        )
                    )
                {
                    e01 = sPixel.Interpolate(c5, c1);
                }
                if (
                    c3.IsLike(c7) && (
                        c4.IsNotLike(c6) ||
                        c4.IsNotLike(c2) ||
                        c3.IsNotLike(c0) ||
                        c7.IsNotLike(c8)
                        )
                    )
                {
                    e10 = sPixel.Interpolate(c3, c7);
                }
                if (
                    c7.IsLike(c5) && (
                        c4.IsNotLike(c8) ||
                        c4.IsNotLike(c0) ||
                        c7.IsNotLike(c6) ||
                        c5.IsNotLike(c2)
                        )
                    )
                {
                    e11 = sPixel.Interpolate(c7, c5);
                }
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #24
0
        /// <summary>
        /// SNES9x's EPX3 modified by Hawkynt to support thresholds
        /// </summary>
        public static void Epx3(IPixelWorker <sPixel> worker)
        {
            var    c0 = worker.SourceM1M1();
            var    c1 = worker.SourceP0M1();
            var    c2 = worker.SourceP1M1();
            var    c3 = worker.SourceM1P0();
            var    c4 = worker.SourceP0P0();
            var    c5 = worker.SourceP1P0();
            var    c6 = worker.SourceM1P1();
            var    c7 = worker.SourceP0P1();
            var    c8 = worker.SourceP1P1();
            sPixel e01, e02, e10, e11, e12, e20, e21, e22;
            var    e00 = e01 = e02 = e10 = e11 = e12 = e20 = e21 = e22 = c4;

            if (c3.IsNotLike(c5) && c7.IsNotLike(c1))
            {
                var neq40 = c4.IsNotLike(c0);
                var neq41 = c4.IsNotLike(c1);
                var neq42 = c4.IsNotLike(c2);
                var neq43 = c4.IsNotLike(c3);
                var neq45 = c4.IsNotLike(c5);
                var neq46 = c4.IsNotLike(c6);
                var neq47 = c4.IsNotLike(c7);
                var neq48 = c4.IsNotLike(c8);

                var eq13 = c1.IsLike(c3) && (neq40 || neq48 || c1.IsNotLike(c2) || c3.IsNotLike(c6));
                var eq37 = c3.IsLike(c7) && (neq46 || neq42 || c3.IsNotLike(c0) || c7.IsNotLike(c8));
                var eq75 = c7.IsLike(c5) && (neq48 || neq40 || c7.IsNotLike(c6) || c5.IsNotLike(c2));
                var eq51 = c5.IsLike(c1) && (neq42 || neq46 || c5.IsNotLike(c8) || c1.IsNotLike(c0));
                if (
                    !neq40 ||
                    !neq41 ||
                    !neq42 ||
                    !neq43 ||
                    !neq45 ||
                    !neq46 ||
                    !neq47 ||
                    !neq48
                    )
                {
                    if (eq13)
                    {
                        e00 = sPixel.Interpolate(c1, c3);
                    }
                    if (eq51)
                    {
                        e02 = sPixel.Interpolate(c5, c1);
                    }
                    if (eq37)
                    {
                        e20 = sPixel.Interpolate(c3, c7);
                    }
                    if (eq75)
                    {
                        e22 = sPixel.Interpolate(c7, c5);
                    }

                    if (eq51 && neq40 && eq13 && neq42)
                    {
                        e01 = sPixel.Interpolate(c1, c3, c5);
                    }
                    else if (eq51 && neq40)
                    {
                        e01 = sPixel.Interpolate(c1, c5);
                    }
                    else if (eq13 && neq42)
                    {
                        e01 = sPixel.Interpolate(c1, c3);
                    }

                    if (eq13 && neq46 && eq37 && neq40)
                    {
                        e10 = sPixel.Interpolate(c3, c1, c7);
                    }
                    else if (eq13 && neq46)
                    {
                        e10 = sPixel.Interpolate(c3, c1);
                    }
                    else if (eq37 && neq40)
                    {
                        e10 = sPixel.Interpolate(c3, c7);
                    }

                    if (eq75 && neq42 && eq51 && neq48)
                    {
                        e12 = sPixel.Interpolate(c5, c1, c7);
                    }
                    else if (eq75 && neq42)
                    {
                        e12 = sPixel.Interpolate(c5, c7);
                    }
                    else if (eq51 && neq48)
                    {
                        e12 = sPixel.Interpolate(c5, c1);
                    }

                    if (eq37 && neq48 && eq75 && neq46)
                    {
                        e21 = sPixel.Interpolate(c7, c3, c5);
                    }
                    else if (eq75 && neq46)
                    {
                        e21 = sPixel.Interpolate(c7, c5);
                    }
                    else if (eq37 && neq48)
                    {
                        e21 = sPixel.Interpolate(c7, c3);
                    }
                }
                else
                {
                    if (eq13)
                    {
                        e00 = sPixel.Interpolate(c1, c3);
                    }
                    if (eq51)
                    {
                        e02 = sPixel.Interpolate(c5, c1);
                    }
                    if (eq37)
                    {
                        e20 = sPixel.Interpolate(c3, c7);
                    }
                    if (eq75)
                    {
                        e22 = sPixel.Interpolate(c7, c5);
                    }
                }
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP2P0(e02);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
            worker.TargetP2P1(e12);
            worker.TargetP0P2(e20);
            worker.TargetP1P2(e21);
            worker.TargetP2P2(e22);
        }
Пример #25
0
        /// <summary>
        /// Kreed's SuperSaI
        /// </summary>
        public static void SuperSaI(IPixelWorker <sPixel> worker)
        {
            var c0 = worker.SourceM1M1();
            var c1 = worker.SourceP0M1();
            var c2 = worker.SourceP1M1();
            var d3 = worker.SourceP2M1();
            var c3 = worker.SourceM1P0();
            var c4 = worker.SourceP0P0();
            var c5 = worker.SourceP1P0();
            var d4 = worker.SourceP2P0();
            var c6 = worker.SourceM1P1();
            var c7 = worker.SourceP0P1();
            var c8 = worker.SourceP1P1();
            var d5 = worker.SourceP2P1();
            var d0 = worker.SourceM1P2();
            var d1 = worker.SourceP0P2();
            var d2 = worker.SourceP1P2();
            var d6 = worker.SourceP2P2();

            sPixel e01, e10, e11;
            var    e00 = e01 = e11 = c4;

            if (c7.IsLike(c5) && c4.IsNotLike(c8))
            {
                var c57 = sPixel.Interpolate(c7, c5);
                e11 = c57;
                e01 = c57;
            }
            else if (c4.IsLike(c8) && c7.IsNotLike(c5))
            {
                //nothing
            }
            else if (c4.IsLike(c8) && c7.IsLike(c5))
            {
                var c57    = sPixel.Interpolate(c7, c5);
                var c48    = sPixel.Interpolate(c4, c8);
                var conc2D = 0;
                conc2D += _Conc2D(c57, c48, c6, d1);
                conc2D += _Conc2D(c57, c48, c3, c1);
                conc2D += _Conc2D(c57, c48, d2, d5);
                conc2D += _Conc2D(c57, c48, c2, d4);

                if (conc2D > 0)
                {
                    e11 = c57;
                    e01 = c57;
                }
                else if (conc2D == 0)
                {
                    e11 = sPixel.Interpolate(c48, c57);
                    e01 = sPixel.Interpolate(c48, c57);
                }
            }
            else
            {
                if (c8.IsLike(c5) && c8.IsLike(d1) && c7.IsNotLike(d2) && c8.IsNotLike(d0))
                {
                    e11 = sPixel.Interpolate(sPixel.Interpolate(c8, c5, d1), c7, 3, 1);
                }
                else if (c7.IsLike(c4) && c7.IsLike(d2) && c7.IsNotLike(d6) && c8.IsNotLike(d1))
                {
                    e11 = sPixel.Interpolate(sPixel.Interpolate(c7, c4, d2), c8, 3, 1);
                }
                else
                {
                    e11 = sPixel.Interpolate(c7, c8);
                }
                if (c5.IsLike(c8) && c5.IsLike(c1) && c5.IsNotLike(c0) && c4.IsNotLike(c2))
                {
                    e01 = sPixel.Interpolate(sPixel.Interpolate(c5, c8, c1), c4, 3, 1);
                }
                else if (c4.IsLike(c7) && c4.IsLike(c2) && c5.IsNotLike(c1) && c4.IsNotLike(d3))
                {
                    e01 = sPixel.Interpolate(sPixel.Interpolate(c4, c7, c2), c5, 3, 1);
                }
                else
                {
                    e01 = sPixel.Interpolate(c4, c5);
                }
            }
            if (c4.IsLike(c8) && c4.IsLike(c3) && c7.IsNotLike(c5) && c4.IsNotLike(d2))
            {
                e10 = sPixel.Interpolate(c7, sPixel.Interpolate(c4, c8, c3));
            }
            else if (c4.IsLike(c6) && c4.IsLike(c5) && c7.IsNotLike(c3) && c4.IsNotLike(d0))
            {
                e10 = sPixel.Interpolate(c7, sPixel.Interpolate(c4, c6, c5));
            }
            else
            {
                e10 = c7;
            }

            if (c7.IsLike(c5) && c7.IsLike(c6) && c4.IsNotLike(c8) && c7.IsNotLike(c2))
            {
                e00 = sPixel.Interpolate(sPixel.Interpolate(c7, c5, c6), c4);
            }
            else if (c7.IsLike(c3) && c7.IsLike(c8) && c4.IsNotLike(c6) && c7.IsNotLike(c0))
            {
                e00 = sPixel.Interpolate(sPixel.Interpolate(c7, c3, c8), c4);
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }
Пример #26
0
        // TODO: to be really exact, the comparisons are not that right by comparing to already interpolated values
        // TODO: when interpolating 3 or more points I'm using already calculated interpolations and weight them further
        //       which is not the mathematically correct approach, but it's enough - at least for now
        /// <summary>
        /// Kreed's SuperEagle modified by Hawkynt to allow thresholds
        /// </summary>
        public static void SuperEagle(IPixelWorker <sPixel> worker)
        {
            var c0 = worker.SourceM1M1();
            var c1 = worker.SourceP0M1();
            var c2 = worker.SourceP1M1();
            var c3 = worker.SourceM1P0();
            var c4 = worker.SourceP0P0();
            var c5 = worker.SourceP1P0();
            var d4 = worker.SourceP2P0();
            var c6 = worker.SourceM1P1();
            var c7 = worker.SourceP0P1();
            var c8 = worker.SourceP1P1();
            var d5 = worker.SourceP2P1();
            var d1 = worker.SourceP0P2();
            var d2 = worker.SourceP1P2();

            sPixel e00 = c4, e11 = c4;
            sPixel e01, e10;

            if (c4.IsLike(c8))
            {
                var c48 = sPixel.Interpolate(c4, c8);
                if (c7.IsLike(c5))
                {
                    var c57    = sPixel.Interpolate(c5, c7);
                    var conc2D = 0;
                    conc2D += _Conc2D(c57, c48, c6, d1);
                    conc2D += _Conc2D(c57, c48, c3, c1);
                    conc2D += _Conc2D(c57, c48, d2, d5);
                    conc2D += _Conc2D(c57, c48, c2, d4);

                    if (conc2D > 0)
                    {
                        e10 = c57;
                        e01 = c57;
                        e11 = sPixel.Interpolate(c48, c57);
                        e00 = sPixel.Interpolate(c48, c57);
                    }
                    else if (conc2D < 0)
                    {
                        e10 = sPixel.Interpolate(c48, c57);
                        e01 = sPixel.Interpolate(c48, c57);
                    }
                    else
                    {
                        e10 = c57;
                        e01 = c57;
                    }
                }
                else
                {
                    if (c48.IsLike(c1) && c48.IsLike(d5))
                    {
                        e01 = sPixel.Interpolate(sPixel.Interpolate(c48, c1, d5), c5, 3, 1);
                    }
                    else if (c48.IsLike(c1))
                    {
                        e01 = sPixel.Interpolate(sPixel.Interpolate(c48, c1), c5, 3, 1);
                    }
                    else if (c48.IsLike(d5))
                    {
                        e01 = sPixel.Interpolate(sPixel.Interpolate(c48, d5), c5, 3, 1);
                    }
                    else
                    {
                        e01 = sPixel.Interpolate(c48, c5);
                    }

                    if (c48.IsLike(d2) && c48.IsLike(c3))
                    {
                        e10 = sPixel.Interpolate(sPixel.Interpolate(c48, d2, c3), c7, 3, 1);
                    }
                    else if (c48.IsLike(d2))
                    {
                        e10 = sPixel.Interpolate(sPixel.Interpolate(c48, d2), c7, 3, 1);
                    }
                    else if (c48.IsLike(c3))
                    {
                        e10 = sPixel.Interpolate(sPixel.Interpolate(c48, c3), c7, 3, 1);
                    }
                    else
                    {
                        e10 = sPixel.Interpolate(c48, c7);
                    }
                }
            }
            else
            {
                if (c7.IsLike(c5))
                {
                    var c57 = sPixel.Interpolate(c5, c7);
                    e01 = c57;
                    e10 = c57;

                    if (c57.IsLike(c6) && c57.IsLike(c2))
                    {
                        e00 = sPixel.Interpolate(sPixel.Interpolate(c57, c6, c2), c4, 3, 1);
                    }
                    else if (c57.IsLike(c6))
                    {
                        e00 = sPixel.Interpolate(sPixel.Interpolate(c57, c6), c4, 3, 1);
                    }
                    else if (c57.IsLike(c2))
                    {
                        e00 = sPixel.Interpolate(sPixel.Interpolate(c57, c2), c4, 3, 1);
                    }
                    else
                    {
                        e00 = sPixel.Interpolate(c57, c4);
                    }

                    if (c57.IsLike(d4) && c57.IsLike(d1))
                    {
                        e11 = sPixel.Interpolate(sPixel.Interpolate(c57, d4, d1), c8, 3, 1);
                    }
                    else if (c57.IsLike(d4))
                    {
                        e11 = sPixel.Interpolate(sPixel.Interpolate(c57, d4), c8, 3, 1);
                    }
                    else if (c57.IsLike(d1))
                    {
                        e11 = sPixel.Interpolate(sPixel.Interpolate(c57, d1), c8, 3, 1);
                    }
                    else
                    {
                        e11 = sPixel.Interpolate(c57, c8);
                    }
                }
                else
                {
                    e11 = sPixel.Interpolate(c8, c7, c5, 6, 1, 1);
                    e00 = sPixel.Interpolate(c4, c7, c5, 6, 1, 1);
                    e10 = sPixel.Interpolate(c7, c4, c8, 6, 1, 1);
                    e01 = sPixel.Interpolate(c5, c4, c8, 6, 1, 1);
                }
            }

            worker.TargetP0P0(e00);
            worker.TargetP1P0(e01);
            worker.TargetP0P1(e10);
            worker.TargetP1P1(e11);
        }