public Statistics Diff(TestPresentationImage other) { if (other == null) throw new ArgumentNullException(); List<int> diffs = new List<int>(); using (Bitmap thatBitmap = other.DrawToBitmap(_width, _height)) { using (Bitmap thisBitmap = this.DrawToBitmap(_width, _height)) { for (int x = 0; x < _width; x++) { for (int y = 0; y < _height; y++) { Color thatColor = thatBitmap.GetPixel(x, y); Color thisColor = thisBitmap.GetPixel(x, y); diffs.Add(Math.Abs(thatColor.R - thisColor.R)); diffs.Add(Math.Abs(thatColor.G - thisColor.G)); diffs.Add(Math.Abs(thatColor.B - thisColor.B)); diffs.Add(Math.Abs(thatColor.A - thisColor.A)); } } } } return new Statistics(diffs); }
public void TestBasicGrayscaleImage16() { const int rows = 8; const int cols = 8; var pixelData = new byte[rows*cols*2]; using (var imageGraphic = new GrayscaleImageGraphic(rows, cols, 16, 16, 15, false, false, 1, 0, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }
public void TestBasicGrayscaleImage16() { const int rows = 8; const int cols = 8; var pixelData = new byte[rows * cols * 2]; using (var imageGraphic = new GrayscaleImageGraphic(rows, cols, 16, 16, 15, false, false, 1, 0, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }
public void TestBasicColorImage() { const int rows = 8; const int cols = 8; var pixelData = new byte[rows * cols * 4]; using (var imageGraphic = new ColorImageGraphic(rows, cols, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }
public void TestInvalidPixelDataGrayscaleImage16() { const int rows = 8; const int cols = 8; try { var badPixelData = new byte[rows * cols * 2 - 10]; using (var imageGraphic = new GrayscaleImageGraphic(rows, cols, 16, 16, 15, false, false, 1, 0, () => badPixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } Assert.Fail("Expected RenderingException was not thrown"); } catch (RenderingException ex) { Trace.WriteLine(string.Format("Rendering exception thrown: {0}", ex.UserMessage)); } }
public void TestInvalidPixelDataGrayscaleImage8() { const int rows = 8; const int cols = 8; try { var badPixelData = new byte[rows*cols - 10]; using (var imageGraphic = new GrayscaleImageGraphic(rows, cols, 8, 8, 7, false, false, 1, 0, () => badPixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } Assert.Fail("Expected RenderingException was not thrown"); } catch (RenderingException ex) { Trace.WriteLine(string.Format("Rendering exception thrown: {0}", ex.UserMessage)); } }
public void TestMaximumPracticalColorImage() { if (Assert64Bit()) { return; } // due to the 2GB limit for a single buffer and the current ImageViewer rendering infrastructure, // it is not possible to render the largest possible valid-DICOM color image. // these values test the maximum renderable image under the current infrastructure assuming a 64-bit machine const int rows = (1 << 15) - 1; const int cols = (1 << 14); var pixelData = new byte[rows * cols * 4]; using (var imageGraphic = new ColorImageGraphic(rows, cols, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }
public void TestMaximumPracticalColorImage() { if (Assert64Bit()) return; // due to the 2GB limit for a single buffer and the current ImageViewer rendering infrastructure, // it is not possible to render the largest possible valid-DICOM color image. // these values test the maximum renderable image under the current infrastructure assuming a 64-bit machine const int rows = (1 << 15) - 1; const int cols = (1 << 14); var pixelData = new byte[rows*cols*4]; using (var imageGraphic = new ColorImageGraphic(rows, cols, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }
public void TestBasicColorImage() { const int rows = 8; const int cols = 8; var pixelData = new byte[rows*cols*4]; using (var imageGraphic = new ColorImageGraphic(rows, cols, () => pixelData)) using (var presentationImage = new TestPresentationImage(imageGraphic)) { presentationImage.DrawToBitmap(100, 100); } }