示例#1
0
        public override void Prepare(DrawInfo info)
        {
            // Prepare inputs:
            base.Prepare(info);

            if (info.Mode == SurfaceDrawMode.CPU)
            {
                // Prerender now! Bitmap node will sample it as needed.

                int width  = info.ImageX;
                int height = info.ImageY;

                // Set buffer etc:
                Setup(info);

                // Setup secondary buffer:
                if (Buffer2 == null || Buffer2.Length != Buffer.Length)
                {
                    Buffer2 = new Color[Buffer.Length];
                }

                Width  = width;
                Height = height;

                // Render into buffer2:
                SourceModule.DrawCPU(info, Buffer2);

                // Get radii:
                int hRadius = (int)(width * RadiusX.GetValue(0.0, 0.0));
                int vRadius = (int)(height * RadiusY.GetValue(0.0, 0.0));

                // Do percentile filter now:
                PercentileFilter.Filter(Buffer2, Buffer, width, height, hRadius, vRadius, Percent);
            }
        }
示例#2
0
        public override void Prepare(DrawInfo info)
        {
            base.Prepare(info);

            if (info.Mode == SurfaceDrawMode.CPU)
            {
                // Prerender source now!

                int width  = info.ImageX;
                int height = info.ImageY;

                // Buffer etc:
                Setup(info);

                // Setup secondary buffer:
                if (Buffer2 == null || Buffer2.Length != Buffer.Length)
                {
                    Buffer2 = new Color[Buffer.Length];
                }

                // Draw source now:
                SourceModule.DrawCPU(info, Buffer2);

                Width  = width;
                Height = height;

                // Get radii:
                float hRadius = (float)(width * RadiusX.GetValue(0.0, 0.0));
                float vRadius = (float)(height * RadiusY.GetValue(0.0, 0.0));

                // Box or gaus blur:
                if (Method_ == (int)BlurMethod.Box)
                {
                    // Blurs and flips (horizontal for vertical):
                    BoxBlurFilter.BlurAndTranspose(Buffer2, Buffer, width, height, (int)hRadius);
                    BoxBlurFilter.BlurAndTranspose(Buffer, Buffer2, height, width, (int)vRadius);
                }
                else
                {
                    Kernel kernelH = GaussianFilter.MakeKernel(hRadius);
                    Kernel kernelV;

                    if (vRadius == hRadius)
                    {
                        kernelV = kernelH;
                    }
                    else
                    {
                        kernelV = GaussianFilter.MakeKernel(vRadius);
                    }

                    // Blurs and flips (horizontal for vertical):
                    GaussianFilter.ConvolveAndTranspose(kernelH, Buffer2, Buffer, width, height, true, ConvolveWrapping.ClampEdges);
                    GaussianFilter.ConvolveAndTranspose(kernelV, Buffer, Buffer2, height, width, true, ConvolveWrapping.ClampEdges);
                }
            }
        }