コード例 #1
0
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            if (blur != 0)
            {
                // Call the Gaussian Blur function
                blurEffect.Render(new Rectangle[] { rect }, 0, 1);
            }
            else
            {
                dst.CopySurface(shadowSurface, rect.Location, rect);
            }

            Rectangle selection  = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
            Rectangle shadowRect = Rectangle.FromLTRB(
                selection.Left + margin + offsetX,
                selection.Top + margin + offsetY,
                selection.Right - margin + offsetX,
                selection.Bottom - margin + offsetY);
            ColorBgra shadowPixel;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    shadowPixel   = dst[x, y];
                    shadowPixel.A = shadowRect.Contains(x, y) ? Int32Util.ClampToByte(shadowPixel.A * color.A / byte.MaxValue) : byte.MinValue;

                    dst[x, y] = normalOp.Apply(src[x, y], shadowPixel);
                }
            }
        }
コード例 #2
0
        public void GaussianBlurEffect2()
        {
            var src = GetSourceImage("input.png");

            var effect = new GaussianBlurEffect(100);

            effect.Render(src);

            Compare(src, "gaussianblur2.png");
        }