1

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>

David Božjak
  • 16,887
  • 18
  • 67
  • 98
Matthew
  • 3,976
  • 15
  • 66
  • 130

1 Answers1

0

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.

David Božjak
  • 16,887
  • 18
  • 67
  • 98
  • I had to create the `Windows.UI.Color` as in my original post because it did not accept byte values when being created. But all in all your solution worked. Thanks! Now I just have to find some good values to input to create a good looking filter. Any recommendations, or perhaps links of others' samples? – Matthew Jan 05 '14 at 15:42
  • @Matthew Well you can cast the values to byte even in the constructor. – David Božjak Jan 05 '14 at 15:49
  • I suppose in WP8's version the constructor takes no arguments. – Matthew Jan 05 '14 at 16:07
  • 1
    @Matthew you are correct. You should use Color.FromArgb method. I updated my sample to reflect this. – David Božjak Jan 07 '14 at 07:43