public void As_Bitmap_Throws() { var image = new WPFImage(100, 100); image.Render(3, false, false, 0); Assert.Throws <DicomImagingException>(() => image.As <Bitmap>()); }
public IImage RenderImage(ILUT lut) { DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawText(_text, new Point(ScaledOffsetX, ScaledOffsetY)); drawingContext.Close(); RenderTargetBitmap bmp = new RenderTargetBitmap(ScaledWidth, ScaledHeight, 96, 96, PixelFormats.Bgra32); bmp.Render(drawingVisual); var overlay = new int[ScaledWidth * ScaledHeight]; var stride = ScaledWidth * 4; bmp.CopyPixels(overlay, stride, 0); var image = new WPFImage(ScaledWidth, ScaledHeight); image.AsWriteableBitmap().WritePixels( new Int32Rect(ScaledOffsetX, ScaledOffsetY, ScaledWidth, ScaledHeight), overlay, stride, 0); return(image); }
public void As_BitmapSource_ReturnsBitmapSource() { var image = new WPFImage(100, 100); image.Render(3, false, false, 0); Assert.IsAssignableFrom <BitmapSource>(image.As <BitmapSource>()); }
public void As_Bitmap_Throws() { var image = new WPFImage(100, 100); image.Render(3, false, false, 0); Assert.Throws(typeof(DicomImagingException), () => image.As<Bitmap>()); }
public void As_BitmapSource_ReturnsBitmapSource() { var image = new WPFImage(100, 100); image.Render(3, false, false, 0); Assert.IsAssignableFrom<BitmapSource>(image.As<BitmapSource>()); }