protected void DeserializeDisplayShutter(DisplayShutterModuleIod displayShutterModule, T image) { ShutterShape shape = displayShutterModule.ShutterShape; if (shape != ShutterShape.Bitmap && shape != ShutterShape.None) { IShutterGraphic shutter = DicomGraphicsFactory.CreateGeometricShuttersGraphic(displayShutterModule, image.Frame.Rows, image.Frame.Columns); // Some day, we will properly deserialize CIELab colours - until then, leave PresentationColor default black DicomGraphicsPlane dicomGraphicsPlane = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true); dicomGraphicsPlane.Shutters.Add(shutter); dicomGraphicsPlane.Shutters.Activate(shutter); } }
private static void DeserializeHeader(IDicomPresentationImage image) { bool anyFailures = false; DicomGraphicsPlane dicomGraphicsPlane = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true); if (dicomGraphicsPlane == null) { throw new DicomGraphicsDeserializationException("Unknown exception."); } // Check if the image header specifies a bitmap display shutter BitmapDisplayShutterModuleIod bitmapShutterIod = new BitmapDisplayShutterModuleIod(image.ImageSop.DataSource); int bitmapShutterIndex = -1; if (bitmapShutterIod.ShutterShape == ShutterShape.Bitmap) { bitmapShutterIndex = bitmapShutterIod.ShutterOverlayGroupIndex; } if (bitmapShutterIndex < 0 || bitmapShutterIndex > 15) { bitmapShutterIndex = -1; } try { GeometricShuttersGraphic geometricShuttersGraphic = DicomGraphicsFactory.CreateGeometricShuttersGraphic(image.Frame); dicomGraphicsPlane.Shutters.Add(geometricShuttersGraphic); } catch (Exception e) { anyFailures = true; Platform.Log(LogLevel.Warn, e, "An error occurred trying to create geometric shutter graphics from the image header."); } try { List <OverlayPlaneGraphic> overlayPlaneGraphics = DicomGraphicsFactory.CreateOverlayPlaneGraphics(image.Frame); foreach (OverlayPlaneGraphic overlay in overlayPlaneGraphics) { if (bitmapShutterIndex != -1 && overlay.Index == bitmapShutterIndex) { // Someday when we support CIELab colour, we should set presentation value/colour based on client display type if (bitmapShutterIod.ShutterPresentationValue != null) { overlay.GrayPresentationValue = (ushort)bitmapShutterIod.ShutterPresentationValue; } overlay.Color = null; // insert the bitmap shutter into the shutters graphic instead of with the other overlays dicomGraphicsPlane.Shutters.Add(overlay); } else if (overlay.Index >= 0 && overlay.Index < 16) { // otherwise just add the overlay to the default layer for overlays and activate immediately dicomGraphicsPlane.ImageOverlays.Add(overlay); dicomGraphicsPlane.ImageOverlays.ActivateAsLayer(overlay, "OVERLAY"); } else { // otherwise just add the overlay to the default layer for overlays and activate immediately dicomGraphicsPlane.UserOverlays.Add(overlay); dicomGraphicsPlane.UserOverlays.ActivateAsLayer(overlay, "OVERLAY"); } } } catch (Exception e) { anyFailures = true; Platform.Log(LogLevel.Warn, e, "An error occurred trying to create overlay graphics from the image header."); } dicomGraphicsPlane.Shutters.ActivateFirst(); if (anyFailures) { throw new DicomGraphicsDeserializationException("At least one failure occurred in deserializing graphics from the image header."); } }