是否有一种简单的方法来缩放和模糊Windows

是否有一种简单的方法来缩放和模糊Windows

本文介绍了WP8:是否有一种简单的方法来缩放和模糊Windows Phone应用程序的BitmapImage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在开发一款可以通过MediaPlayer API从音乐文件中动态阅读专辑艺术的Windows Phone应用。我希望获得专辑艺术并调整视图的背景。由于调整大小会丢失细节并使图像变得难看,所以我想模糊它或某种效果。有没有我可以模糊图像的API? (来自C#还是XAML)?非常感谢!

I am working on a windows Phone app that can read Album arts dynamically from Music files through MediaPlayer APIs. I wish to get album arts and resize for view's background. Since the resize would lose details and make image ugly so I would like to blur it or some kind of effect. Is there any API that I can blur the image? (either from C# or XAML)? Thanks a lot!

推荐答案

我首先要使用WriteableBitmap,要从BitmapImage获取WriteableBitmap,您可以执行以下操作:

I would start by using WriteableBitmap instead, to get a WriteableBitmap from a BitmapImage you can do the following:

WriteableBitmap wb = new WriteableBitmap(bitmapImage);

然后我建议使用。它支持调整图像大小:

Then I would recommend using the WriteableBitmapExtension library. It has support for resizing the image:

wb.Resize(newWidth, newHeight, WriteableBitmapExtensions.Interpolation.Bilinear);

要做执行以下操作(由于某种原因,concolution不会编辑writableBitmap,因此您必须再次将其分配给相同的writableBitmap以查看结果):

To do the gaussian blur with WritableBitmapExtensions do the following (for some reason concolution doesn't edit the writableBitmap, so you have to assign it again to the same writableBitmap to see the result):

wb = wb.Convolute(WriteableBitmapExtensions.KernelGaussianBlur5x5);

wb = wb.Convolute(WriteableBitmapExtensions.KernelGaussianBlur3x3);

(相邻像素的权重不同)。

(Just different weights for the neighbouring pixels).

这篇关于WP8:是否有一种简单的方法来缩放和模糊Windows Phone应用程序的BitmapImage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:24