public AnnObject ToAnnObject(
IDicomAnnotationObject dicomAnnotationObject
)
dicomAnnotationObject
The DICOM annotation object that is being converted
An AnnObject representation of the DICOM annotation if successful; null if the Leadtools.Dicom.DicomAnnotationObject cannot be converted.
Note that if the Leadtools.IDicomAnnotationObject is a Leadtools.Dicom.DicomCompoundGraphic, and the objects are 'grouped', then the conversion might not return the original Leadtools.Annotations.Engine.AnnObject. For example, if the original Leadtools.Annotations.Engine.AnnObject is a Leadtools.Annotations.Engine.AnnPolyRulerObject, it will be converted to two Leadtools.Dicom.DicomCompoundGraphic rulers, with the same Leadtools.Dicom.DicomCompoundGraphic.GraphicGroupId. Using this method to convert back to an Leadtools.Annotations.Engine.AnnObject, the method will be called twice two return two rulers. So in this case, it is better to use Leadtools.Annotations.Engine.AnnObject, as this will convert to the original Leadtools.Annotations.Engine.AnnPolyRulerObject.
This example does the following:
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Dicom.Annotations;
using Leadtools.Annotations;
using Leadtools.Annotations.Engine;
private AnnObject DicomAnnotationsUtilities_ToAnnObject()
{
// Create a compound graphic -- Rectangle
DicomCompoundGraphic compoundGraphic = new DicomCompoundGraphic();
compoundGraphic.LayerName = "Layer 0";
compoundGraphic.Units = DicomAnnotationUnitsRelativityType.Pixel;
compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Rectangle;
DicomAnnotationPoint[] pts = new DicomAnnotationPoint[2];
pts[0] = new DicomAnnotationPoint(100, 100);
pts[1] = new DicomAnnotationPoint(200, 200);
compoundGraphic.SetAnnotationPoints(pts, pts.Length);
compoundGraphic.CompoundGraphicInstanceId = 200;
compoundGraphic.GraphicGroupId = 0;
compoundGraphic.RotationAngle = 45.0;
compoundGraphic.RotationPoint = new DicomAnnotationPoint(150, 150);
compoundGraphic.Filled = true;
compoundGraphic.Options = DicomAnnotationOptions.Fill | DicomAnnotationOptions.Line | DicomAnnotationOptions.CompoundGraphicInstanceId;
// LineStyle
compoundGraphic.LineStyle = new DicomLineStyle();
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.None;
compoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off;
compoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = new ushort[3] { 1, 2, 3 };
compoundGraphic.LineStyle.PatternOnColorCieLabValue = new ushort[3] { 24886, 53484, 50171 }; // red
compoundGraphic.LineStyle.PatternOffColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.LineStyle.LineThickness = 2.0f;
compoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.Solid;
compoundGraphic.LineStyle.LinePattern = 0xFFFF;
compoundGraphic.LineStyle.PatternOnOpacity = 1.0f;
compoundGraphic.LineStyle.PatternOffOpacity = 0.0f;
// FillStyle
compoundGraphic.FillStyle = new DicomFillStyle();
compoundGraphic.FillStyle.FillOptions = DicomAnnotationFillOptions.None;
compoundGraphic.FillStyle.PatternOnColorCieLabValue = new ushort[3] { 21169, 53249, 5175 }; // blue
compoundGraphic.FillStyle.PatternOffColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.FillStyle.PatternOnOpacity = 1.0f;
compoundGraphic.FillStyle.PatternOffOpacity = 0.0f;
compoundGraphic.FillStyle.FillMode = DicomAnnotationFillModeType.Solid;
// Set up the DicomAnnotationsUtilities converter
DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();
du.ImageDpiX = 96.0;
du.ImageDpiY = 96.0;
du.DisplayWidth = 200;
du.DisplayHeight = 200;
du.LayerName = "Layer 0";
// Convert the DICOM Annotation to a LEAD annotation
AnnObject annObjectResult = du.ToAnnObject(compoundGraphic);
return annObjectResult;
}