コード例 #1
0
ファイル: BlurFilter.cs プロジェクト: eriser/nsynth
        private void BoxBlurRGB24(BitmapRGB24 input, BitmapRGB24 output, BitmapRGB32 mask = null)
        {
            Contract.Requires(input != null);
            Contract.Requires(output != null);
            Contract.Requires(input.Width == output.Width);
            Contract.Requires(input.Height == output.Height);

            int radius = this.Radius;
            int w = input.Width;
            int h = input.Height;
            var bmp = output;

            var pix = bmp.Pixels;
            float div = (float)Math.Pow((radius * 2 + 1), 2);

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    var tr = 0.0;
                    var tg = 0.0;
                    var tb = 0.0;

                    for (int ky = -radius; ky <= radius; ky++)
                    {
                        for (int kx = -radius; kx <= radius; kx++)
                        {
                            var px = Math.Max(Math.Min(x + kx, w - 1), 0);
                            var py = Math.Max(Math.Min(y + ky, h - 1), 0);
                            var p = input[px, py];
                            tr += p.Red;
                            tg += p.Green;
                            tb += p.Blue;
                            //div += 1;
                        }
                    }
                    //total.Alpha = 1.0f;
                    bmp[x, y] = new ColorRGB24((byte)(tr / 255.0 * (255.0 / div)),
                        (byte)(tg / 255.0 * (255.0 / div)), (byte)(tb / 255.0 * (255.0 / div)));
                }
            }
        }
コード例 #2
0
        private void BoxBlurRGB24(BitmapRGB24 input, BitmapRGB24 output, BitmapRGB32 mask = null)
        {
            Contract.Requires(input != null);
            Contract.Requires(output != null);
            Contract.Requires(input.Width == output.Width);
            Contract.Requires(input.Height == output.Height);

            int radius = this.Radius;
            int w      = input.Width;
            int h      = input.Height;
            var bmp    = output;

            var   pix = bmp.Pixels;
            float div = (float)Math.Pow((radius * 2 + 1), 2);

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    var tr = 0.0;
                    var tg = 0.0;
                    var tb = 0.0;

                    for (int ky = -radius; ky <= radius; ky++)
                    {
                        for (int kx = -radius; kx <= radius; kx++)
                        {
                            var px = Math.Max(Math.Min(x + kx, w - 1), 0);
                            var py = Math.Max(Math.Min(y + ky, h - 1), 0);
                            var p  = input[px, py];
                            tr += p.Red;
                            tg += p.Green;
                            tb += p.Blue;
                            //div += 1;
                        }
                    }
                    //total.Alpha = 1.0f;
                    bmp[x, y] = new ColorRGB24((byte)(tr / 255.0 * (255.0 / div)),
                                               (byte)(tg / 255.0 * (255.0 / div)), (byte)(tb / 255.0 * (255.0 / div)));
                }
            }
        }
コード例 #3
0
ファイル: BlurFilter.cs プロジェクト: eriser/nsynth
 private void BoxBlurRGB32(BitmapRGB32 input, BitmapRGB32 output, BitmapRGB32 mask = null)
 {
     Contract.Requires(input != null);
     Contract.Requires(output != null);
 }
コード例 #4
0
ファイル: ContrastEffectFilter.cs プロジェクト: eriser/nsynth
 private BitmapRGB32 ApplyEffectRGB32(BitmapRGB32 input)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 private BitmapRGB32 ApplyEffectRGB32(BitmapRGB32 input)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
 private void BoxBlurRGB32(BitmapRGB32 input, BitmapRGB32 output, BitmapRGB32 mask = null)
 {
     Contract.Requires(input != null);
     Contract.Requires(output != null);
 }