【问题标题】:Switch Foreground and Background for Nokia Imaging SDK: BlendFilter()切换诺基亚成像 SDK 的前景和背景:BlendFilter()
【发布时间】:2014-12-19 16:05:04
【问题描述】:

我正在尝试使用 Nokia Imaging SDK 将使用 ChromaKeyFilter 的图像混合到背景图像上。我也想在同一个渲染过程中这样做。

到目前为止,我得到了这个:

IList<IFilter> finalFilters = new List<IFilter>();
finalFilters.Add(_chromaKeyFilter);
finalFilters.Add(blendFilter);

但是,现在背景图像在顶部,当然应该反过来。我可以以某种方式切换这个吗?或者这甚至是正确的方法吗?谢谢。

【问题讨论】:

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


【解决方案1】:

在典型情况下,您有一个背景图像(使用一个 *ImageSource 设置)和一个前景图像(使用另一个 *ImageSource 设置)。

ChromaKeyFilter(在 FilterEffect 中)可以看作是一种修饰符,它可以在图像中创建透明度。在这里它被应用于前景,这基本上会在设置与像素匹配的地方切掉透明孔(零 alpha)。

然后将 BlendFilter(在 another FilterEffect 中)应用于背景,将前景中的 FilterEffect 作为其 ForegroundSource 以将前景图像放在其顶部。

尝试使用伪代码的示例:

// Foreground chain:
var fg = new BufferImageSource(...);
var fgWithTransparency = new FilterEffect(fg) 
{ 
    Filters = new [] { new ChromaKeyFilter(...) }
};

// Background/compositing chain:
var bg = new BufferImageSource(...);
var bgAndFgComposited = new FilterEffect(bg) 
{ 
    Filters = new [] { new BlendFilter(fgWithTransparency) }
};

如果您现在渲染 bgFilterEffect,您将获得显示 bg 和顶部混合的 fg 的合成结果。

【讨论】:

  • 谢谢,您为我节省了很多代码、时间和精力 :-) 现在唯一的问题是我的最终 jpeg 包含背景的捕获器日期,这导致其中的位置错误相机胶卷。关于如何解决这个问题的任何想法?
  • 我刚刚注意到 - 当您将 .RemoveExif 设置为 true 时,日期将被重置。 NVM ;-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-04
相关资源
最近更新 更多