Пример #1
0
        public void IndexingTest()
        {
            // Arrange
            FileStream pngStream = new FileStream("half.png", FileMode.Open, FileAccess.Read);

            int[] indexes = new int[] { 0, 1, 12, 37, 56, 132, 200 };

            // Act
            var image = new Bitmap(pngStream);

            TempDoubleImageFormat test3d = new TempDoubleImageFormat(ReadTo3DDoubles(image));
            TempDoubleImageFormat test1d = new TempDoubleImageFormat(ReadTo1DDoubles(image), image.Width, image.Height, 3);

            // Assert
            for (int x = 0; x < indexes.Length; x++)
            {
                for (int y = 0; y < indexes.Length; y++)
                {
                    double[] pixel3d = test3d.GetPixelChannels(x, y);
                    double[] pixel1d = test1d.GetPixelChannels(x, y);

                    CollectionAssert.AreEqual(pixel3d, pixel1d, $"Pixels at {x} x {y} should be equal");
                }
            }
        }
Пример #2
0
        public void CheckThatRawContentWorks()
        {
            // Arrange
            FileStream pngStream = new FileStream("half.png", FileMode.Open, FileAccess.Read);

            // Act
            var image = new Bitmap(pngStream);

            double[] doubles1d             = ReadTo1DDoubles(image);
            TempDoubleImageFormat test1d_1 = new TempDoubleImageFormat(doubles1d, image.Width, image.Height, 3, createCopy: true);

            // Assert
            Assert.Greater(doubles1d.Length, 1000, "There should be some bytes in image data");
            CollectionAssert.AreEqual(doubles1d, test1d_1.GetRawContent());
        }
    /// <summary>
    /// Constructor for temp double image format
    /// </summary>
    /// <param name="input">Existing TempDoubleImageFormat</param>
    public TempDoubleImageFormat(TempDoubleImageFormat input)
    {
        if (input.content1d != null)
        {
            this.content1d = input.content1d;
            this.content3d = null;
        }
        else
        {
            this.content3d = input.content3d;
            this.content1d = null;
        }

        this.width            = input.width;
        this.height           = input.height;
        this.channelsPerPixel = input.channelsPerPixel;
    }
Пример #4
0
        public void LoadTest1d()
        {
            // Arrange
            FileStream pngStream = new FileStream("half.png", FileMode.Open, FileAccess.Read);

            // Act
            var   image      = new Bitmap(pngStream);
            Color firstColor = image.GetPixel(0, 0);

            TempDoubleImageFormat test = new TempDoubleImageFormat(ReadTo1DDoubles(image), image.Width, image.Height, 3);

            double[] firstPixel = test.GetPixelChannels(0, 0);

            // Assert
            Assert.AreEqual(firstColor.R / byteMax, firstPixel[0]);
            Assert.AreEqual(firstColor.G / byteMax, firstPixel[1]);
            Assert.AreEqual(firstColor.B / byteMax, firstPixel[2]);
        }
Пример #5
0
        public void CheckThat1dCopyWorks()
        {
            // Arrange
            FileStream pngStream = new FileStream("half.png", FileMode.Open, FileAccess.Read);

            // Act
            var image = new Bitmap(pngStream);

            double[] doubles1d             = ReadTo1DDoubles(image);
            TempDoubleImageFormat test1d_1 = new TempDoubleImageFormat(doubles1d, image.Width, image.Height, 3, createCopy: false);
            TempDoubleImageFormat test1d_2 = new TempDoubleImageFormat(doubles1d, image.Width, image.Height, 3, createCopy: true);

            doubles1d[0] = 0.0;

            double[] firstPixel1 = test1d_1.GetPixelChannels(0, 0);
            double[] firstPixel2 = test1d_2.GetPixelChannels(0, 0);

            // Assert
            Assert.AreEqual(0.0, firstPixel1[0]);
            Assert.AreNotEqual(0.0, firstPixel2[0]);
        }