QuickFont.QBitmap.BlurAlpha C# (CSharp) Method

BlurAlpha() public method

public BlurAlpha ( int radius, int passes ) : void
radius int
passes int
return void
        public void BlurAlpha(int radius, int passes)
        {
            QBitmap tmp = new QBitmap(new Bitmap(this.bitmap.Width, this.bitmap.Height, bitmap.PixelFormat));

            byte a = 0;
            int summedA;
            int weight = 0;
            int xpos, ypos, x, y, kx, ky;
            int width = bitmap.Width;
            int height = bitmap.Height;

            for (int pass = 0; pass < passes; pass++)
            {

                //horizontal pass
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        summedA = weight = 0;
                        for (kx = -radius; kx <= radius; kx++)
                        {
                            xpos = x + kx;
                            if (xpos >= 0 && xpos < width)
                            {
                                GetAlpha32(xpos, y, ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;
                        tmp.PutAlpha32(x, y, (byte)summedA);
                    }
                }




                //vertical pass
                for (x = 0; x <width; ++x)
                {
                    for (y = 0; y < height; ++y)
                    {
                        summedA = weight = 0;
                        for (ky = -radius; ky <= radius; ky++)
                        {
                            ypos = y + ky;
                            if (ypos >= 0 && ypos < height)
                            {
                                tmp.GetAlpha32(x, ypos,ref a);
                                summedA += a;
                                weight++;
                            }
                        }

                        summedA /= weight;

                        PutAlpha32(x, y, (byte)summedA);

                    }
                }

            }

            tmp.Free();

        }