Exemplo n.º 1
0
        public void Test_IndexOutOfRange()
        {
            using (MagickImage image = new MagickImage(Color.Red, 5, 10))
            {
                using (PixelCollection pixels = image.GetReadOnlyPixels())
                {
                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        pixels.GetValue(5, 0);
                    });

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        pixels.GetValue(-1, 0);
                    });

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        pixels.GetValue(0, -1);
                    });

                    ExceptionAssert.Throws <ArgumentException>(delegate()
                    {
                        pixels.GetValue(0, 10);
                    });
                }
            }
        }
Exemplo n.º 2
0
        public void Test_IndexOutOfRange()
        {
            using (MagickImage image = new MagickImage(MagickColors.Red, 5, 10))
            {
                using (PixelCollection pixels = image.GetPixels())
                {
                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(4, 0, 2, 1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(new MagickGeometry(0, 9, 1, 2));
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(-1, 0, 1, 1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(0, -1, 1, 1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(0, 0, -1, 1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetArea(0, 0, 1, -1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetValue(5, 0);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetValue(-1, 0);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetValue(0, -1);
                    });

                    ExceptionAssert.Throws <ArgumentOutOfRangeException>(delegate()
                    {
                        pixels.GetValue(0, 10);
                    });
                }
            }
        }
Exemplo n.º 3
0
        private static void Test_PixelColor(PixelCollection pixels, int x, int y, MagickColor color)
        {
            var values = pixels.GetValue(x, y);

            Assert.AreEqual(3, values.Length);

            MagickColor magickColor = new MagickColor(values[0], values[1], values[2]);

            ColorAssert.AreEqual(color, magickColor);
        }
Exemplo n.º 4
0
        public void Test_GetValue()
        {
            using (MagickImage image = new MagickImage(MagickColors.Red, 5, 10))
            {
                using (PixelCollection pixels = image.GetPixels())
                {
                    var values = pixels.GetValue(0, 0);
                    Assert.AreEqual(3, values.Length);

                    MagickColor color = new MagickColor(values[0], values[1], values[2]);
                    ColorAssert.AreEqual(MagickColors.Red, color);
                }
            }
        }
Exemplo n.º 5
0
        private int lineScan_H(PixelCollection pPixels, int pLine, int pWidth)
        {
            var pixelTotal = 0;
            var scanCount  = 0;

            for (var x = 0; x < pWidth; x += _pixelSkipRateH)
            {
                pixelTotal += pPixels.GetValue(x, pLine)[0];
                scanCount++;
            }

            var _return = pixelTotal / scanCount;

            return(_return);
        }
Exemplo n.º 6
0
        private int lineScan_V(PixelCollection pPixels, int pLine, int pHeight)
        {
            var pixelTotal = 0;
            var scanCount  = 0;

            for (var x = 0; x < pHeight; x += _pixelSkipRateV)
            {
                pixelTotal += pPixels.GetValue(pLine, x)[0];
                scanCount++;
            }
            scanCount--;

            var _return = pixelTotal / scanCount;

            return(_return);
        }