Windows Phone - 快速模糊效果用于背景中的位图图像

时间:2013-11-14 21:10:05

标签: c# image silverlight image-processing windows-phone

我在200x200分辨率的页面中心使用了艺术家的封面图像。我想将此图像重复到背景但是更改它,以便用户可以识别颜色和一些大的形状。我不确定哪个名字在英文中有这种效果。我认为像blug,smoothing等类似的东西。

我发现这段代码可以满足我的需求:

coverBitmap.ImageOpened += (s, args) =>
{
  var wb = new WriteableBitmap((BitmapImage)s);
  var newHeight = 800;
  wb = wb.Resize(newHeight, newHeight, WriteableBitmapExtensions.Interpolation.Bilinear);
  wb = wb.Crop(new Rect(160, 0, 480, 800));
  wb = wb.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
  var brush = new ImageBrush {ImageSource = wb};
  LayoutRoot.Background = brush;
};

问题在于KernelGaussianBlur5x5它仍然太尖锐(精确)。我为19x19创建了自己的矩阵:

var array = new[,]
                {
                    {16, 17, 19, 20, 21, 22, 23, 24, 24, 24, 24, 24, 23, 22, 21, 20, 19, 17, 16},
                    {17, 19, 20, 22, 23, 24, 25, 26, 26, 26, 26, 26, 25, 24, 23, 22, 20, 19, 17},
                    {19, 20, 22, 24, 25, 26, 27, 28, 28, 28, 28, 28, 27, 26, 25, 24, 22, 20, 19},
                    {20, 22, 24, 25, 27, 28, 29, 30, 30, 30, 30, 30, 29, 28, 27, 25, 24, 22, 20},
                    {21, 23, 25, 27, 28, 29, 31, 31, 32, 32, 32, 31, 31, 29, 28, 27, 25, 23, 21},
                    {22, 24, 26, 28, 29, 31, 32, 33, 33, 33, 33, 33, 32, 31, 29, 28, 26, 24, 22},
                    {23, 25, 27, 29, 31, 32, 33, 34, 34, 35, 34, 34, 33, 32, 31, 29, 27, 25, 23},
                    {24, 26, 28, 30, 31, 33, 34, 35, 35, 36, 35, 35, 34, 33, 31, 30, 28, 26, 24},
                    {24, 26, 28, 30, 32, 33, 34, 35, 36, 36, 36, 35, 34, 33, 32, 30, 28, 26, 24},
                    {24, 26, 28, 30, 32, 33, 35, 36, 36, 36, 36, 36, 35, 33, 32, 30, 28, 26, 24},
                    {24, 26, 28, 30, 32, 33, 34, 35, 36, 36, 36, 35, 34, 33, 32, 30, 28, 26, 24},
                    {24, 26, 28, 30, 31, 33, 34, 35, 35, 36, 35, 35, 34, 33, 31, 30, 28, 26, 24},
                    {23, 25, 27, 29, 31, 32, 33, 34, 34, 35, 34, 34, 33, 32, 31, 29, 27, 25, 23},
                    {22, 24, 26, 28, 29, 31, 32, 33, 33, 33, 33, 33, 32, 31, 29, 28, 26, 24, 22},
                    {21, 23, 25, 27, 28, 29, 31, 31, 32, 32, 32, 31, 31, 29, 28, 27, 25, 23, 21},
                    {20, 22, 24, 25, 27, 28, 29, 30, 30, 30, 30, 30, 29, 28, 27, 25, 24, 22, 20},
                    {19, 20, 22, 24, 25, 26, 27, 28, 28, 28, 28, 28, 27, 26, 25, 24, 22, 20, 19},
                    {17, 19, 20, 22, 23, 24, 25, 26, 26, 26, 26, 26, 25, 24, 23, 22, 20, 19, 17},
                    {16, 17, 19, 20, 21, 22, 23, 24, 24, 24, 24, 24, 23, 22, 21, 20, 19, 17, 16}
                };

我不确定我是否正确创造了它。我从WinForm应用程序的Microsoft示例中找到了示例,结果为double[,],因此我乘以10000 a然后将其保存到int[,]。但是,当我将其应用于我的代码时,创建新图像需要几秒钟,我仍然希望它更模糊。

那么有什么方法可以快速调整大小(展开)和裁剪图像然后模糊(涂抹,平滑)呢?感谢

0 个答案:

没有答案