Frage

I'm trying to use the Nokia Imaging SDK to blend an image I used the ChromaKeyFilter on onto a background image. I'd also like to to this in the same rendering process.

So far I've got this:

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

However, now the background image is on top, which of course should be the other way arround. Can I somehow switch this? Or is this even the right way to go? Thanks.

War es hilfreich?

Lösung

In the typical case, you have a background image (set up using one *ImageSource) and a foreground image (set up using another *ImageSource).

The ChromaKeyFilter (in a FilterEffect) can be seen as a modifier, one that creates transparency in the image. Here it is applied to the foreground, this basically cuts out transparent holes (zero alpha) wherever the settings match the pixels.

The BlendFilter (in another FilterEffect) is then applied on the background, taking the FilterEffect from the foreground as its ForegroundSource to put the foreground image on top of it.

Attempt at example using pseudo code:

// 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) }
};

If you now render bgFilterEffect you get the composited result showing bg with the fg blended on top.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top