public virtual bool RenderImage(System.IO.MemoryStream ms, out int w, out int h, bool bRotate90 = false) { int frame = 0; if (frame != CurrentFrame || _pixelData == null) { Load(Dataset, frame); } var graphic = new ImageGraphic(_pixelData); if (ShowOverlays) { foreach (var overlay in _overlays) { if ((frame + 1) < overlay.OriginFrame || (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1)) { continue; } var og = new OverlayGraphic( PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor); graphic.AddOverlay(og); og.Scale(this._scale); } } return(graphic.RenderImage(this._pipeline.LUT, ms, out w, out h, bRotate90)); }
/// <summary>Renders DICOM image to <see cref="IImage"/>.</summary> /// <param name="frame">Zero indexed frame number</param> /// <returns>Rendered image</returns> public virtual IImage RenderImage(int frame = 0) { if (frame != CurrentFrame || _pixelData == null) { Load(Dataset, frame); } var graphic = new ImageGraphic(_pixelData); if (ShowOverlays) { foreach (var overlay in _overlays) { if ((frame + 1) < overlay.OriginFrame || (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1)) { continue; } var og = new OverlayGraphic( PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor); graphic.AddOverlay(og); og.Scale(this._scale); } } return(graphic.RenderImage(this._pipeline.LUT)); }
/// <summary>Renders DICOM image to <see cref="IImage"/>.</summary> /// <param name="frame">Zero indexed frame number.</param> /// <returns>Rendered image</returns> public virtual IImage RenderImage(int frame = 0) { IPixelData pixels; lock (_lock) { var load = frame >= 0 && (frame != CurrentFrame || _rerender); CurrentFrame = frame; _rerender = false; if (load) { var frameIndex = GetFrameIndex(frame); pixels = PixelDataFactory.Create(_pixelData, frameIndex).Rescale(_scale); _pixels = pixels; } else { pixels = _pixels; } } if (ShowOverlays) { EstablishGraphicsOverlays(); } IImage image; var graphic = new ImageGraphic(pixels); if (ShowOverlays) { foreach (var overlay in _overlays) { if (overlay.Data is EmptyBuffer)//fixed overlay.data is null, exception thrown { continue; } if (frame + 1 < overlay.OriginFrame || frame + 1 > overlay.OriginFrame + overlay.NumberOfFrames - 1) { continue; } var og = new OverlayGraphic( PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor); graphic.AddOverlay(og); og.Scale(_scale); } } image = graphic.RenderImage(_pipeline.LUT); return(image); }
/// <summary>Renders DICOM image to <see cref="IImage"/>.</summary> /// <param name="frame">Zero indexed frame number.</param> /// <returns>Rendered image</returns> public virtual IImage RenderImage(int frame = 0) { bool load; lock (_lock) { load = frame >= 0 && (frame != CurrentFrame || _rerender); _currentFrame = frame; _rerender = false; } var frameIndex = GetFrameIndex(frame); if (load) { lock (_lock) { _pixels = PixelDataFactory.Create(_pixelData, frameIndex).Rescale(_scale); } } if (ShowOverlays) { EstablishGraphicsOverlays(); } IImage image; lock (_lock) { var graphic = new ImageGraphic(_pixels); if (ShowOverlays) { foreach (var overlay in _overlays) { if (frame + 1 < overlay.OriginFrame || frame + 1 > overlay.OriginFrame + overlay.NumberOfFrames - 1) { continue; } var og = new OverlayGraphic( PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor); graphic.AddOverlay(og); og.Scale(_scale); } } image = graphic.RenderImage(_pipeline.LUT); } return(image); }
/// <summary>Renders DICOM image to System.Drawing.Image</summary> /// <returns>Rendered image</returns> #if !SILVERLIGHT public Image RenderImage() { ImageGraphic graphic = new ImageGraphic(_pixelData); foreach (var overlay in _overlays) { OverlayGraphic og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX, overlay.OriginY, OverlayColor); graphic.AddOverlay(og); } return graphic.RenderImage(_pipeline.LUT); }
/// <summary>Renders DICOM image to System.Drawing.Image</summary> /// <param name="frame">Zero indexed frame number</param> /// <returns>Rendered image</returns> public Image RenderImage(int frame = 0) { if (frame != _currentFrame || _pixelData == null) { Load(Dataset, frame); } ImageGraphic graphic = new ImageGraphic(_pixelData); foreach (var overlay in _overlays) { OverlayGraphic og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX, overlay.OriginY, OverlayColor); graphic.AddOverlay(og); } return(graphic.RenderImage(_pipeline.LUT)); }
/// <summary>Renders DICOM image to System.Drawing.Image</summary> /// <param name="frame">Zero indexed frame number</param> /// <returns>Rendered image</returns> public Image RenderImage(int frame = 0) { if (frame != _currentFrame || _pixelData == null) { Load(Dataset, frame); } var graphic = new ImageGraphic(_pixelData); try { if (ShowOverlays) { foreach (var overlay in _overlays) { if ((frame + 1) < overlay.OriginFrame || (frame + 1) > (overlay.OriginFrame + overlay.NumberOfFrames - 1)) { continue; } var og = new OverlayGraphic(PixelDataFactory.Create(overlay), overlay.OriginX - 1, overlay.OriginY - 1, OverlayColor); graphic.AddOverlay(og); og.Scale(this._scale); } } var image = graphic.RenderImage(_pipeline.LUT); return(new Bitmap(image)); } finally { if (graphic != null) { graphic.Dispose(); } } }
/// <summary>Renders DICOM image to System.Drawing.Image</summary> /// <returns>Rendered image</returns> public Image Render() { ImageGraphic graphic = new ImageGraphic(_pixelData); return(graphic.RenderImage(_pipeline.LUT)); }