0

这没有给我任何结果。代码有什么问题?顺便说一句,下面的代码模糊了图像。

var ImgFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/search.png"));
var wb = new WriteableBitmap(1, 1);
using (var strm = await ImgFile.OpenReadAsync())
{
    wb.SetSource(strm);
}
var wb2 = new WriteableBitmap(wb.PixelWidth,wb.PixelHeight);
var wb3 = WriteableBitmapExtensions.Convolute(wb2, WriteableBitmapExtensions.KernelGaussianBlur5x5);
PageBackground.Source = wb3;
4

1 回答 1

1

您正在将图像加载到 wb 图像中,但您没有使用它来模糊(相反,您只是模糊了空的 wb2)。这应该有效:

var ImgFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/search.png"));
var wb = new WriteableBitmap(1, 1);
using (var strm = await ImgFile.OpenReadAsync())
{
     wb=await wb.FromStream(strm);
}
var wb3 = WriteableBitmapExtensions.Convolute(wb, WriteableBitmapExtensions.KernelGaussianBlur5x5);
PageBackground.Source = wb3;
于 2013-09-23T16:03:08.423 回答