How to Create SplitToneRange for SplitToneFilter in Nokia Imaging SDK

68 Views Asked by At

I am a bit confused by the SplitToneRange IList required for SplitToneFilter.

SplitToneFilter(IList<SplitToneRange> splitToneRanges)

How does one create such ranges? I did the following but I'm not sure if I am going about this correctly.

Windows.UI.Color c = new Windows.UI.Color();
c.R = (byte)155;
c.G = (byte)155;
c.B = (byte)155;
SplitToneRange r = new SplitToneRange(20, 80, c);
SplitToneRange r1 = new SplitToneRange(140, 200, c);

Is this a correct start? And if so, how might I add this to the SplitToneRange(..).

I try creating an IList

IList<SplitToneRange> l = new IList<SplitToneRange>(); //error

But I get the following error

Cannot create an instance of the abstact class or interface System.Collections.Generic.IList<Nokia.Graphics.Imaging.SplitToneRange>

1

There are 1 best solutions below

4
On BEST ANSWER

You can not create an instance of an interface (in your case IList). This isn't a limitation of the Imaging SDK, it's just how C# works. Just create a normal list:

List<SplitToneRange> list = new List<SplitToneRange>();

And then add some SplitToneRanges to it:

list.Add(new SplitToneRange(20, 80, Windows.UI.Color.FromArgb(255, 155, 155, 155)));
list.Add(new SplitToneRange(140, 200, Windows.UI.Color.FromArgb(255, 30, 80, 200)));

SplitToneFilter filter = new SplitToneFilter(list);

The rest of your code looks correct (haven't tried it), but usually you will have different colors for different SplitToneRanges, as in my example. Try experimenting with the values to get the feel for what the SplitToneFilter actually does.