将BitmapImage加载到WriteableBitmap中,但不存在任何方法 [英] Load BitmapImage into WriteableBitmap but no method existing
问题描述
在Windows 8中,WriteableBitmap
类的构造函数仅采用两个参数:该对象的高度和宽度.同时,对于Silverlight,它接受BitmapImage
对象作为参数. (在MSDN上验证: WriteableBitmap.WriteableBitmap构造函数)
The constructor of WriteableBitmap
class with Windows 8 only takes two arguments: the height and the width of this object. Meanwhile with Silverlight it accepts a BitmapImage
object as argument. (Verified on MSDN : WriteableBitmap.WriteableBitmap constructor)
我想加载此BitmapImage
,因为我试图模糊我的Assets文件夹中已经存在的图像.
I would like to load this BitmapImage
because I'm trying to blur an image which already exists on my Assets folder.
推荐答案
感谢您的帮助,我成功使我的形象模糊了.这是为了将BitmapImage链接到WriteableBitmap对象的示例:
Thanks for your help, I succeed to blur my image. Here is the sample in order to link the BitmapImage into the WriteableBitmap object :
BitmapImage bi = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));
WriteableBitmap wb = new WriteableBitmap(bi.PixelWidth, bi.PixelHeight);
var streamFile = await GetFileStream(myFile);
await wb.SetSourceAsync(streamFile);
wb = wb.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);
然后只需将WriteableBitmap写入LocalStorage!
Then just write the WriteableBitmap into the LocalStorage !
这篇关于将BitmapImage加载到WriteableBitmap中,但不存在任何方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!