将BitmapImage加载到WriteableBitmap中,但不存在任何方法 [英] Load BitmapImage into WriteableBitmap but no method existing

查看:102
本文介绍了将BitmapImage加载到WriteableBitmap中,但不存在任何方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆