Beispiel #1
0
        public void ColorBGR16_Accessor()
        {
            byte r = (byte)NextComponent(byte.MaxValue);
            byte g = (byte)NextComponent(byte.MaxValue);
            byte b = (byte)NextComponent(byte.MaxValue);

            ColorBGR16 v = new ColorBGR16(r, g, b);
            float      c;

            Assert.DoesNotThrow(() => c = v[0]);
            Assert.DoesNotThrow(() => c = v[1]);
            Assert.DoesNotThrow(() => c = v[2]);
            Assert.Throws <IndexOutOfRangeException>(() => c = v[+3]);
            Assert.Throws <IndexOutOfRangeException>(() => c = v[-1]);

            Assert.DoesNotThrow(() => v[0] = 1.0f);
            Assert.DoesNotThrow(() => v[1] = 1.0f);
            Assert.DoesNotThrow(() => v[2] = 1.0f);
            Assert.Throws <IndexOutOfRangeException>(() => v[+3] = 0.0f);
            Assert.Throws <IndexOutOfRangeException>(() => v[-1] = 0.0f);

            Assert.DoesNotThrow(() => v[2] = 0.0f);
            Assert.DoesNotThrow(() => v[2] = 1.0f);
            Assert.Throws <InvalidOperationException>(() => v[2] = -1.0f);
            Assert.Throws <InvalidOperationException>(() => v[2] = +1.1f);
        }
Beispiel #2
0
        public void ColorBGR16_CastFromColor()
        {
            const double Epsilon = 0.25;

            Random random = new Random();
            double r      = NextComponent(random, 1.0);
            double g      = NextComponent(random, 1.0);
            double b      = NextComponent(random, 1.0);

            Color c = Color.FromArgb(byte.MaxValue, (int)(r * byte.MaxValue), (int)(g * byte.MaxValue), (int)(b * byte.MaxValue));

            ColorBGR16 v = (ColorBGR16)c;

            Assert.AreEqual((float)r, v[0], Epsilon);
            Assert.AreEqual((float)g, v[1], Epsilon);
            Assert.AreEqual((float)b, v[2], Epsilon);

            // Not influenced by alpha
            c = Color.FromArgb(0, (int)(r * byte.MaxValue), (int)(g * byte.MaxValue), (int)(b * byte.MaxValue));
            v = (ColorBGR16)c;

            Assert.AreEqual((float)r, v[0], Epsilon);
            Assert.AreEqual((float)g, v[1], Epsilon);
            Assert.AreEqual((float)b, v[2], Epsilon);
        }
Beispiel #3
0
        public void ColorBGR16_PixelType()
        {
            byte r = (byte)NextComponent(byte.MaxValue);
            byte g = (byte)NextComponent(byte.MaxValue);
            byte b = (byte)NextComponent(byte.MaxValue);

            ColorBGR16 v = new ColorBGR16(r, g, b);

            Assert.AreNotEqual(PixelLayout.None, v.PixelType);
        }
Beispiel #4
0
        public void ColorBGR16_TestConstructor1()
        {
            byte r = (byte)byte.MaxValue;
            byte g = (byte)byte.MaxValue;
            byte b = (byte)byte.MaxValue;

            ColorBGR16 v = new ColorBGR16(r, g, b);

            Assert.AreEqual(r, v.Red);
            Assert.AreEqual(g, v.Green);
            Assert.AreEqual(b, v.Blue);
        }