诺基亚Imaging SDK定制BlendFilter [英] nokia Imaging SDK customize BlendFilter

查看:91
本文介绍了诺基亚Imaging SDK定制BlendFilter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了这段代码

Uri _blendImageUri = new Uri(@"Assets/1.png", UriKind.Relative);
var _blendImageProvider = new StreamImageSource((System.Windows.Application.GetResourceStream(_blendImageUri).Stream));

var bf = new BlendFilter(_blendImageProvider);

过滤器工作正常.但是我想更改ForegroundSource属性的图像大小.如何以我的尺寸加载图像?

Filter work nice. But I want change image size for ForegroundSource property. How can I load image with my size?

推荐答案

如果我对您的理解正确,那么您正在尝试将ForegroundSource与原始图像的一部分混合吗? BlendFilter本身目前不支持这种方式,称为 local blending .

If I understood you correctly you are trying to blend ForegroundSource with only a part of the original image? That is called local blending at it is currently not supported on the BlendFilter itself.

但是,您可以使用ReframingFilter重新构架ForegroundSource,然后将其融合.您的链条看起来像这样:

You can however use ReframingFilter to reframe the ForegroundSource and then blend it. Your chain will look like something like this:

using (var mainImage = new StreamImageSource(...))
using (var filterEffect = new FilterEffect(mainImage))
{
    using (var secondaryImage = new StreamImageSource(...))
    using (var secondaryFilterEffect = new FilterEffect(secondaryImage))
    using (var reframing = new ReframingFilter(new Rect(0, 0, 500, 500), 0))    //reframe your image, thus "setting" the location and size of the content when blending
    {
        secondaryFilterEffect.Filters = new [] { reframing };

        using (var blendFilter = new BlendFilter(secondaryFilterEffect)
        using (var renderer = new JpegRenderer(filterEffect))
        {
            filterEffect.Filters = new [] { blendFilter };

            await renderer.RenderAsync();
        }
    }
}

如您所见,您可以使用重构成滤镜来定位ForegroundSource的内容,使其仅在本地混合.请注意,在重新构图时,您可以在图像位置之外设置边框(例如,新的Rect(-100,-100,500,500)),图像外部的区域将显示为黑色透明区域-正是您所需要的BlendFilter.

As you can see, you can use the reframing filter to position the content of your ForegroundSource so that it will only blend locally. Note that when reframeing you can set the borders outside of the image location (for example new Rect(-100, -100, 500, 500)) and the areas outside of the image will appear as black transparent areas - exactly what you need in BlendFilter.

这篇关于诺基亚Imaging SDK定制BlendFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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