Пример #1
0
        public void CopyGreyPixels()
        {
            var src = new MemoryBitmap <float>(177, 177).Slice((10, 10, 150, 150));
            var dst = new MemoryBitmap <Byte>(177, 177).Slice((10, 10, 150, 150));

            src.SetPixels(1);

            var(min, max) = SpanBitmap.MinMax(src);
            Assert.AreEqual(min, 1);
            Assert.AreEqual(max, 1);

            SpanBitmap.CopyPixels(src, dst, (0, 128), (0, 255));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel == 128));

            SpanBitmap.CopyPixels(src, dst, (0, 1), (10, 255));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel == 10));

            SpanBitmap.CopyPixels(src, dst, (0, 1), (2, 3));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel == 2));
        }
Пример #2
0
        public void CopyRGBPixels()
        {
            var src = new MemoryBitmap <Vector3>(177, 177).Slice((10, 10, 150, 150));
            var dst = new MemoryBitmap <PixelBGR>(177, 177).Slice((10, 10, 150, 150));

            src.SetPixels(Vector3.One);

            Assert.IsTrue(SpanBitmap.ArePixelsEqual(src, src));

            SpanBitmap.CopyPixels(src, dst, (0, 128), (0, 255));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel.Equals(new PixelBGR(128))));

            SpanBitmap.CopyPixels(src, dst, (0, 1), (10, 255));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel.Equals(new PixelBGR(10))));

            SpanBitmap.CopyPixels(src, dst, (0, 1), (2, 3));
            Assert.IsTrue(dst.EnumeratePixels().All(p => p.Pixel.Equals(new PixelBGR(2))));

            Assert.IsTrue(SpanBitmap.ArePixelsEqual(dst, dst));
        }