public void ShouldGetBitmapWithoutWritingIt()
        {
            // Arrange
            var expectedWidth  = 5;
            var expectedHeight = 21;
            var segy           = new MockSegyFile(expectedWidth, expectedHeight);

            // Act
            Bitmap image = Subject.GetBitmap((ISegyFile)segy);

            // Assert
            Assert.AreEqual(expectedWidth, image.Width);
            Assert.AreEqual(expectedHeight, image.Height);
            image.Dispose();
        }
        public void ShouldHaveCorrectResolution()
        {
            // Arrange
            var expectedWidth  = 7;
            var expectedHeight = 11;
            var segy           = new MockSegyFile(expectedWidth, expectedHeight);
            var path           = TestPath() + ".png";

            // Act
            Subject.Write(segy, path);

            // Assert
            using (var image = Bitmap.FromFile(path))
            {
                Assert.AreEqual(expectedWidth, image.Width);
                Assert.AreEqual(expectedHeight, image.Height);
            }
        }
        public void WhenDisabledNullSamplesShouldNotBeTransparent()
        {
            // Arrange
            var trace = new MockTrace {
                Values = new float[] { 0, 1, -1 }
            };
            var segy = new MockSegyFile {
                Traces = new ITrace[] { trace }
            };
            var path = TestPath() + ".png";

            // Act
            Subject.SetNullValuesToTransparent = false;
            Subject.Write(segy, path);

            // Assert
            Bitmap image = new Bitmap(path);

            Assert.AreEqual(255, image.GetPixel(0, 0).A);
        }
        public void PixelValuesShouldBeBlackToWhite()
        {
            // Arrange
            var traceValues = new float[] { 150, 175, 125, 200, 111, 100, 123 };    // Min: 100, Max: 200
            var trace       = new MockTrace {
                Values = traceValues
            };
            var segy = new MockSegyFile {
                Traces = new ITrace[] { trace }
            };
            var path = TestPath() + ".png";

            // Act
            Subject.Write(segy, path);

            // Assert
            Bitmap image = new Bitmap(path);

            Assert.AreEqual(Color.FromArgb(0, 0, 0), image.GetPixel(0, 5));
            Assert.AreEqual(Color.FromArgb(127, 127, 127), image.GetPixel(0, 0));
            Assert.AreEqual(Color.FromArgb(255, 255, 255), image.GetPixel(0, 3));
        }
        public void ShouldCreateImageForEachInline()
        {
            // Arrange
            var values   = new float[] { 1, 2, 3 };
            var trace12a = new MockTrace {
                Header = new MockTraceHeader {
                    InlineNumber = 12, CrosslineNumber = 1
                }, Values = values
            };
            var trace12b = new MockTrace {
                Header = new MockTraceHeader {
                    InlineNumber = 12, CrosslineNumber = 2
                }, Values = values
            };
            var trace14 = new MockTrace {
                Header = new MockTraceHeader {
                    InlineNumber = 14
                }, Values = values
            };
            var segy = new MockSegyFile {
                Traces = new ITrace[] { trace12a, trace12b, trace14 }
            };
            var path = TestPath() + ".png";

            // Act
            Subject.Write(segy, path);

            // Assert
            var image12 = new Bitmap(TestPath() + " (12).png");

            Assert.AreEqual(3, image12.Height);
            Assert.AreEqual(2, image12.Width);
            var image14 = new Bitmap(TestPath() + " (14).png");

            Assert.AreEqual(3, image14.Height);
            Assert.AreEqual(1, image14.Width);
        }
        public void NullSamplesShouldBeTransparent()
        {
            // Arrange: A sample value of exactly 0
            var traceValues = new float[] { 0.00001f, 0, -0.00001f };
            var trace       = new MockTrace {
                Values = traceValues
            };
            var segy = new MockSegyFile {
                Traces = new ITrace[] { trace }
            };
            var path = TestPath() + ".png";

            Subject.SetNullValuesToTransparent = true;

            // Act
            Subject.Write(segy, path);

            // Assert
            Bitmap image = new Bitmap(path);

            Assert.AreEqual(255, image.GetPixel(0, 0).A);
            Assert.AreEqual(0, image.GetPixel(0, 1).A);
            Assert.AreEqual(255, image.GetPixel(0, 2).A);
        }