【问题标题】:How to use the Nokia Imaging SDK's BlendFilter on WP8?如何在 WP8 上使用 Nokia Imaging SDK 的 BlendFilter?
【发布时间】:2014-12-19 16:04:26
【问题描述】:

我正盯着 Nokia Imaging SDK 试一试。现在,我面临的问题是我有一个已经存在的图像(在我的 Visual Studio 解决方案的文件夹中),我想转换这个图像以便在 BlendFilter 类中使用它诺基亚成像 SDK。但是我不知道怎么用。

我试图转换流中的现有图像,然后将其作为参数传递给 BlendFilter 构造函数。但不是运气。编译器说最好的重载方法 match ... 有一些无效的参数。

这是我尝试将现有图像加载到流中的方式:

Image image = new Image();
image.Source = new BitmapImage(new Uri("/Images/Template3.2.png", UriKind.Relative));

BitmapImage bitImage = new BitmapImage(new Uri("/Images/Template3.2.png", UriKind.Relative));

WriteableBitmap Bitmap = new WriteableBitmap(bitImage);

然后:

var BlendFilter = new BlendFilter(bitImage, BlendFunction.Add);  --> the compiler error is here

有人知道如何使用 BlendFilter 类吗?任何例子都会很有帮助。

问候!

【问题讨论】:

    标签: c# windows-phone-8 visual-studio-2013 nokia-imaging-sdk lumia-imaging-sdk


    【解决方案1】:

    混合过滤器将 IImageProvider 作为输入。这意味着您可以使用任何 X-ImageSource 类作为输入,它会在内部完成所有工作。

    如果您有图像流,我建议您创建一个 StreamImageSource 并将其传递给 BlendFilter。

    不同的图片来源列表很长,我建议你查看文档并选择最适合你的那个。

    这是一个将图像流作为输入并在其上混合新图像的示例。为简单起见,其他图像只是填充了一种颜色(ColorImageSource)的图像,但您可以将任何 IImageProvider 设置为源:选择最方便的一个。

    using (var backgroundSource = new StreamImageSource(stream))
    using (var filterEffect = new FilterEffect(backgroundSource))
    {
        using (BlendFilter blendFilter = new BlendFilter()) 
        {
            var size = new Windows.Foundation.Size(400, 400);
            var color = Windows.UI.Color.FromArgb(250, 128, 255, 200);
    
            blendFilter.ForegroundSource = new ColorImageSource(size, color);
            blendFilter.BlendFunction = BlendFunction.Add;
    
            filterEffect.Filters = new[] { blendFilter };
    
            var result = await new JpegRenderer(filterEffect).RenderAsync();
        }
    }
    

    【讨论】:

    • 嗨,David,感谢分享该代码,我帮助我弄清楚了如何做我正在寻找的东西
    • @MikePR 很高兴为您提供帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多