Image 如何使用WriteableBitmapExtension库模糊图像?
这没有给我任何结果。代码怎么了Image 如何使用WriteableBitmapExtension库模糊图像?,image,windows-8,windows-runtime,microsoft-metro,winrt-xaml,Image,Windows 8,Windows Runtime,Microsoft Metro,Winrt Xaml,这没有给我任何结果。代码怎么了 var-ImgFile=wait-Windows.Storage.StorageFile.getfilefromApplicationUrisync(新Uri(“ms”)-appx:///Assets/search.png")); var wb=新的可写比特图(1,1); 使用(var strm=await ImgFile.OpenReadAsync()) { wb.SetSource(strm); } var wb2=新的可写比图(wb.PixelWidth,w
var-ImgFile=wait-Windows.Storage.StorageFile.getfilefromApplicationUrisync(新Uri(“ms”)-appx:///Assets/search.png"));
var wb=新的可写比特图(1,1);
使用(var strm=await ImgFile.OpenReadAsync())
{
wb.SetSource(strm);
}
var wb2=新的可写比图(wb.PixelWidth,wb.PixelHeight);
var wb3=writeablebitmappextensions.convolume(wb2,writeablebitmappextensions.KernelGaussianBlur5x5);
PageBackground.Source=wb3;
您正在将图像加载到wb图像中,但您没有使用它来模糊(相反,您只是模糊空的wb2)。
这应该起作用:
var-ImgFile=wait-Windows.Storage.StorageFile.getfilefromApplicationUrisync(新Uri(“ms”)-appx:///Assets/search.png"));
var wb=新的可写比特图(1,1);
使用(var strm=await ImgFile.OpenReadAsync())
{
wb=等待wb.FromStream(strm);
}
var wb3=writeablebitmappextensions.convolume(wb,writeablebitmappextensions.KernelGaussianBlur5x5);
PageBackground.Source=wb3;
GettingSystem.AccessViolationException-试图读取或写入受保护内存。这通常表示其他内存已损坏。
我刚刚尝试了该代码,如果在SetSource之后添加断点,您将注意到WriteableBitmap尚未加载(像素数已设置,但缓冲区尚未填充),作为一种解决方法,使用wb=wait wb.FromStream(strm);似乎有效。否则,您也可以将流加载到内存中,并在SetSource中使用MemoryStream进行设置,它也应该可以工作。