コード例 #1
0
ファイル: Blur.cs プロジェクト: rtownsend/MOSA-Project
 public RecursiveBlur(RecursizeBlurCalculator recursizeBluerCalculatorFactory)
 {
     m_sum1 = new VectorPOD<RecursizeBlurCalculator>();
     m_sum2 = new VectorPOD<RecursizeBlurCalculator>();
     m_buf = new VectorPOD<RGBA_Bytes>();
     m_RecursizeBlurCalculatorFactory = recursizeBluerCalculatorFactory;
 }
コード例 #2
0
ファイル: Blur.cs プロジェクト: djlw78/Mosa
 public override void Calculate(double b1, double b2, double b3, double b4,
                                RecursizeBlurCalculator c1, RecursizeBlurCalculator c2, RecursizeBlurCalculator c3, RecursizeBlurCalculator c4)
 {
     r = b1 * c1.r + b2 * c2.r + b3 * c3.r + b4 * c4.r;
     g = b1 * c1.g + b2 * c2.g + b3 * c3.g + b4 * c4.g;
     b = b1 * c1.b + b2 * c2.b + b3 * c3.b + b4 * c4.b;
 }
コード例 #3
0
ファイル: Blur.cs プロジェクト: djlw78/Mosa
 public RecursiveBlur(RecursizeBlurCalculator recursizeBluerCalculatorFactory)
 {
     m_sum1 = new VectorPOD <RecursizeBlurCalculator>();
     m_sum2 = new VectorPOD <RecursizeBlurCalculator>();
     m_buf  = new VectorPOD <RGBA_Bytes>();
     m_RecursizeBlurCalculatorFactory = recursizeBluerCalculatorFactory;
 }
コード例 #4
0
ファイル: Blur.cs プロジェクト: rtownsend/MOSA-Project
 public override void Calculate(double b1, double b2, double b3, double b4,
     RecursizeBlurCalculator c1, RecursizeBlurCalculator c2, RecursizeBlurCalculator c3, RecursizeBlurCalculator c4)
 {
     r = b1*c1.r + b2*c2.r + b3*c3.r + b4*c4.r;
     g = b1*c1.g + b2*c2.g + b3*c3.g + b4*c4.g;
     b = b1*c1.b + b2*c2.b + b3*c3.b + b4*c4.b;
     a = b1*c1.a + b2*c2.a + b3*c3.a + b4*c4.a;
 }
コード例 #5
0
ファイル: Blur.cs プロジェクト: rtownsend/MOSA-Project
 public override void Calculate(double b1, double b2, double b3, double b4,
     RecursizeBlurCalculator c1, RecursizeBlurCalculator c2, RecursizeBlurCalculator c3, RecursizeBlurCalculator c4)
 {
     r = b1 * c1.r + b2 * c2.r + b3 * c3.r + b4 * c4.r;
 }
コード例 #6
0
ファイル: Blur.cs プロジェクト: rtownsend/MOSA-Project
 public abstract void Calculate(double b1, double b2, double b3, double b4,
     RecursizeBlurCalculator c1, RecursizeBlurCalculator c2, RecursizeBlurCalculator c3, RecursizeBlurCalculator c4);
コード例 #7
0
ファイル: Blur.cs プロジェクト: djlw78/Mosa
        public void BlurX(IPixelFormat img, double radius)
        {
            if (radius < 0.62)
            {
                return;
            }
            if (img.Width < 3)
            {
                return;
            }

            double s = (double)(radius * 0.5);
            double q = (double)((s < 2.5) ?
                                3.97156 - 4.14554 * Math.Sqrt(1 - 0.26891 * s) :
                                0.98711 * s - 0.96330);

            double q2 = (double)(q * q);
            double q3 = (double)(q2 * q);

            double b0 = (double)(1.0 / (1.578250 +
                                        2.444130 * q +
                                        1.428100 * q2 +
                                        0.422205 * q3));

            double b1 = (double)(2.44413 * q +
                                 2.85619 * q2 +
                                 1.26661 * q3);

            double b2 = (double)(-1.42810 * q2 +
                                 -1.26661 * q3);

            double b3 = (double)(0.422205 * q3);

            double b = (double)(1 - (b1 + b2 + b3) * b0);

            b1 *= b0;
            b2 *= b0;
            b3 *= b0;

            uint w = img.Width;
            uint h = img.Height;
            int  wm = (int)w - 1;
            int  x, y;

            int StartCreatingAt = (int)m_sum1.Size();

            m_sum1.Resize(w);
            m_sum2.Resize(w);
            m_buf.Allocate(w);

            RecursizeBlurCalculator[] Sum1Array = m_sum1.Array;
            RecursizeBlurCalculator[] Sum2Array = m_sum2.Array;
            RGBA_Bytes[] BufferArray            = m_buf.Array;

            for (int i = StartCreatingAt; i < w; i++)
            {
                Sum1Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
                Sum2Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew();
            }

            for (y = 0; y < h; y++)
            {
                RecursizeBlurCalculator c = m_RecursizeBlurCalculatorFactory;
                c.FromPixel(img.Pixel(0, y));
                Sum1Array[0].Calculate(b, b1, b2, b3, c, c, c, c);
                c.FromPixel(img.Pixel(1, y));
                Sum1Array[1].Calculate(b, b1, b2, b3, c, Sum1Array[0], Sum1Array[0], Sum1Array[0]);
                c.FromPixel(img.Pixel(2, y));
                Sum1Array[2].Calculate(b, b1, b2, b3, c, Sum1Array[1], Sum1Array[0], Sum1Array[0]);

                for (x = 3; x < w; ++x)
                {
                    c.FromPixel(img.Pixel(x, y));
                    Sum1Array[x].Calculate(b, b1, b2, b3, c, Sum1Array[x - 1], Sum1Array[x - 2], Sum1Array[x - 3]);
                }

                Sum2Array[wm].Calculate(b, b1, b2, b3, Sum1Array[wm], Sum1Array[wm], Sum1Array[wm], Sum1Array[wm]);
                Sum2Array[wm - 1].Calculate(b, b1, b2, b3, Sum1Array[wm - 1], Sum2Array[wm], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm - 2].Calculate(b, b1, b2, b3, Sum1Array[wm - 2], Sum2Array[wm - 1], Sum2Array[wm], Sum2Array[wm]);
                Sum2Array[wm].ToPixel(ref BufferArray[wm]);
                Sum2Array[wm - 1].ToPixel(ref BufferArray[wm - 1]);
                Sum2Array[wm - 2].ToPixel(ref BufferArray[wm - 2]);

                for (x = wm - 3; x >= 0; --x)
                {
                    Sum2Array[x].Calculate(b, b1, b2, b3, Sum1Array[x], Sum2Array[x + 1], Sum2Array[x + 2], Sum2Array[x + 3]);
                    Sum2Array[x].ToPixel(ref BufferArray[x]);
                }

                unsafe
                {
                    fixed(RGBA_Bytes *pBuffer = BufferArray)
                    {
                        img.CopyHorizontalColorSpan(0, y, w, pBuffer);
                    }
                }
            }
        }
コード例 #8
0
ファイル: Blur.cs プロジェクト: djlw78/Mosa
 public abstract void Calculate(double b1, double b2, double b3, double b4,
                                RecursizeBlurCalculator c1, RecursizeBlurCalculator c2, RecursizeBlurCalculator c3, RecursizeBlurCalculator c4);