예제 #1
0
        public bool Similar(BGRA color1, BGRA color2)
        {
            // Quick exit if same:
            if (color1 == color2)
                return true;

            // Compare YUVA thresholds:
            for (int i = 0; i < 4; ++i)
            {
                int comp1 =
                    s_Matrix[i, 0] * color1.R +
                    s_Matrix[i, 1] * color1.G +
                    s_Matrix[i, 2] * color1.B +
                    s_Matrix[i, 3] * color1.A;
                int comp2 =
                    s_Matrix[i, 0] * color2.R +
                    s_Matrix[i, 1] * color2.G +
                    s_Matrix[i, 2] * color2.B +
                    s_Matrix[i, 3] * color2.A;

                if (Math.Abs(comp1 - comp2) > m_Thresholds[i])
                    return false;
            }

            return true;
        }
        public bool Similar(BGRA color1, BGRA color2)
        {
            // Quick exit if same:
            if (color1 == color2)
            {
                return(true);
            }

            // Compare YUV thresholds:
            for (int i = 0; i < 3; ++i)
            {
                int comp1 =
                    s_Matrix[i, 0] * color1.R +
                    s_Matrix[i, 1] * color1.G +
                    s_Matrix[i, 2] * color1.B;
                int comp2 =
                    s_Matrix[i, 0] * color2.R +
                    s_Matrix[i, 1] * color2.G +
                    s_Matrix[i, 2] * color2.B;

                if (Math.Abs(comp1 - comp2) > m_Thresholds[i])
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
 public BGRA Lerp(BGRA color1, int factor1, BGRA color2, int factor2, BGRA color3, int factor3)
 {
     return BGRA.FromArgb(
         LerpChannel(color1.R, factor1, color2.R, factor2, color3.R, factor3),
         LerpChannel(color1.G, factor1, color2.G, factor2, color3.G, factor3),
         LerpChannel(color1.B, factor1, color2.B, factor2, color3.B, factor3)
         );
 }
예제 #4
0
 private BGRA GetColor(BGRA *Data, int Width, int Height, int x, int y)
 {
     if (x < 0 || y < 0 || x >= Width || y >= Height)
     {
         return(BGRA.FromArgb(0, 0, 0, 0));
     }
     return(Data[y * Width + x]);
 }
        public bool Similar(BGRA color1, BGRA color2)
        {
            // Quick exit if same:
            if (color1 == color2)
            {
                return(true);
            }

            // If both alphas are zero then treat them as the same:
            if (color1.A == 0 && color2.A == 0)
            {
                return(true);
            }

            // Compare alpha thresholds:
            if (Math.Abs((int)color1.A - (int)color2.A) > m_AlphaThreshold)
            {
                return(false);
            }

            // If one of the color's alpha is 0, skip YUV check:
            if (color1.A == 0 || color2.A == 0)
            {
                return(false);
            }

            // Compare YUV thresholds:
            for (int i = 0; i < 3; ++i)
            {
                int comp1 =
                    s_Matrix[i, 0] * color1.R +
                    s_Matrix[i, 1] * color1.G +
                    s_Matrix[i, 2] * color1.B;
                int comp2 =
                    s_Matrix[i, 0] * color2.R +
                    s_Matrix[i, 1] * color2.G +
                    s_Matrix[i, 2] * color2.B;

                if (Math.Abs(comp1 - comp2) > m_Thresholds[i])
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #6
0
        public BGRA Lerp(BGRA color1, int factor1, BGRA color2, int factor2, BGRA color3, int factor3)
        {
            int alphaFactor1 = factor1;
            int alphaFactor2 = factor2;
            int alphaFactor3 = factor3;

            if (color1.A == 0)
                factor1 = 0;
            if (color2.A == 0)
                factor2 = 0;
            if (color3.A == 0)
                factor3 = 0;

            if (factor1 == 0 && factor2 == 0 && factor3 == 0)
                return color1;

            return BGRA.FromArgb(
                LerpChannel(color1.A, alphaFactor1, color2.A, alphaFactor2, color3.A, alphaFactor3),
                LerpChannel(color1.R, factor1, color2.R, factor2, color3.R, factor3),
                LerpChannel(color1.G, factor1, color2.G, factor2, color3.G, factor3),
                LerpChannel(color1.B, factor1, color2.B, factor2, color3.B, factor3)
                );
        }
예제 #7
0
        public bool Similar(BGRA color1, BGRA color2)
        {
            // Quick exit if same:
            if (color1 == color2)
                return true;

            // If both alphas are zero then treat them as the same:
            if (color1.A == 0 && color2.A == 0)
                return true;

            // Compare alpha thresholds:
            if (Math.Abs((int)color1.A - (int)color2.A) > m_AlphaThreshold)
                return false;

            // If one of the color's alpha is 0, skip YUV check:
            if (color1.A == 0 || color2.A == 0)
                return false;

            // Compare YUV thresholds:
            for (int i = 0; i < 3; ++i)
            {
                int comp1 =
                    s_Matrix[i, 0] * color1.R +
                    s_Matrix[i, 1] * color1.G +
                    s_Matrix[i, 2] * color1.B;
                int comp2 =
                    s_Matrix[i, 0] * color2.R +
                    s_Matrix[i, 1] * color2.G +
                    s_Matrix[i, 2] * color2.B;

                if (Math.Abs(comp1 - comp2) > m_Thresholds[i])
                    return false;
            }

            return true;
        }
예제 #8
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
 public BGRA Lerp6x1x1(BGRA color1, BGRA color2, BGRA color3)
 {
     return m_Engine.Lerp.Lerp(color1, 6, color2, 1, color3, 1);
 }
예제 #9
0
 public BGRA Lerp14x1x1(BGRA color1, BGRA color2, BGRA color3)
 {
     return(m_Engine.Lerp.Lerp(color1, 14, color2, 1, color3, 1));
 }
예제 #10
0
 public BGRA Lerp2x3x3(BGRA color1, BGRA color2, BGRA color3)
 {
     return(m_Engine.Lerp.Lerp(color1, 2, color2, 3, color3, 3));
 }
예제 #11
0
 public BGRA Lerp5x2x1(BGRA color1, BGRA color2, BGRA color3)
 {
     return(m_Engine.Lerp.Lerp(color1, 5, color2, 2, color3, 1));
 }
예제 #12
0
 public BGRA Lerp3x1(BGRA color1, BGRA color2)
 {
     return(m_Engine.Lerp.Lerp(color1, 3, color2, 1, BGRA.FromArgb(0, 0, 0, 0), 0));
 }
예제 #13
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
 private BGRA GetColor(BGRA* Data, int Width, int Height, int x, int y)
 {
     if (x < 0 || y < 0 || x >= Width || y >= Height) return BGRA.FromArgb(0, 0, 0, 0);
     return Data[y * Width + x];
 }
예제 #14
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
 public BGRA Lerp5x2x1(BGRA color1, BGRA color2, BGRA color3)
 {
     return m_Engine.Lerp.Lerp(color1, 5, color2, 2, color3, 1);
 }
예제 #15
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
 public BGRA Lerp3x1(BGRA color1, BGRA color2)
 {
     return m_Engine.Lerp.Lerp(color1, 3, color2, 1, BGRA.FromArgb(0, 0, 0, 0), 0);
 }
예제 #16
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
 public BGRA Lerp2x3x3(BGRA color1, BGRA color2, BGRA color3)
 {
     return m_Engine.Lerp.Lerp(color1, 2, color2, 3, color3, 3);
 }
예제 #17
0
파일: Engine.cs 프로젝트: soywiz/cspspemu
            //public Square(Engine engine, Bitmap bitmap, int x, int y)
            public Square(Engine engine, BGRA* Data, int Width, int Height, int x, int y)
            {
                m_Engine = engine;

                // 0 1 2
                // 3 4 5
                // 6 7 8

                m_Colors[0] = GetColor(Data, Width, Height, x - 1, y - 1);
                m_Colors[1] = GetColor(Data, Width, Height, x, y - 1);
                m_Colors[2] = GetColor(Data, Width, Height, x + 1, y - 1);
                m_Colors[3] = GetColor(Data, Width, Height, x - 1, y);
                m_Colors[4] = GetColor(Data, Width, Height, x, y);
                m_Colors[5] = GetColor(Data, Width, Height, x + 1, y);
                m_Colors[6] = GetColor(Data, Width, Height, x - 1, y + 1);
                m_Colors[7] = GetColor(Data, Width, Height, x, y + 1);
                m_Colors[8] = GetColor(Data, Width, Height, x + 1, y + 1);

                // 0 1 2
                // 3   4
                // 5 6 7

                m_Shape[1 << 0] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[0]);
                m_Shape[1 << 1] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[1]);
                m_Shape[1 << 2] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[2]);
                m_Shape[1 << 3] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[3]);
                m_Shape[1 << 4] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[5]);
                m_Shape[1 << 5] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[6]);
                m_Shape[1 << 6] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[7]);
                m_Shape[1 << 7] = m_Engine.Threshold.Similar(m_Colors[4], m_Colors[8]);
            }