Exemple #1
0
        public void TestRedBlue()
        {
            using (var b = CreateImageWithColors(new Color[] { Color.Red, Color.Blue }))
            {
                var results = new ImageTones(2, true).GetWeightedColors(b);
                var colors  = results.Select(t => t.Item1.ToArgb());

                Assert.Contains(Color.Red.ToArgb(), colors);
                Assert.Contains(Color.Blue.ToArgb(), colors);
            }
        }
Exemple #2
0
        public void TestRandom()
        {
            Color[] inputColors = new Color[1000];
            var     r           = new Random();

            for (var i = 0; i < inputColors.Length; i++)
            {
                inputColors[i] = Color.FromArgb(255, 255, r.Next(256), r.Next(256));
            }
            using (var b = CreateImageWithColors(inputColors))
            {
                var results   = new ImageTones(64, true).GetWeightedColors(b);
                var redValues = results.Select(t => t.Item1.R).Distinct().ToArray();
                Assert.Equal(redValues, new byte[] { 255 });
            }
        }