我在页面中心使用了艺术家的封面图片,分辨率为 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[,]
. 但是当我将它应用于我的代码时,创建新图像需要几秒钟,我仍然希望它更加模糊。
那么有没有一种方法可以快速调整(扩展)和裁剪图像然后模糊(涂抹,平滑)它?谢谢