Exemplo n.º 1
0
        /// <summary>Renders DICOM image to System.Drawing.Image</summary>
        /// <param name="frame">Zero indexed frame number</param>
        /// <returns>Rendered image</returns>
        public virtual 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();
                }
            }
        }