예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// MAME's RGB 3x
        /// </summary>
        public static void Rgb3x(IPixelWorker <sPixel> worker)
        {
            var pixel = worker.SourceP0P0();

            worker.TargetP0P0(pixel);
            worker.TargetP1P0(new sPixel(0, pixel.Green, 0, pixel.Alpha));
            worker.TargetP2P0(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            worker.TargetP0P1(new sPixel(0, 0, pixel.Blue, pixel.Alpha));
            worker.TargetP1P1(pixel);
            worker.TargetP2P1(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
            worker.TargetP0P2(new sPixel(pixel.Red, 0, 0, pixel.Alpha));
            worker.TargetP1P2(new sPixel(0, pixel.Green, 0, pixel.Alpha));
            worker.TargetP2P2(pixel);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }