Converts an
AnnObject to a
DicomAnnotationObject.
Syntax
Parameters
- annObject
-
The LEAD annotation object that is being converted
Return Value
A DICOM annotation
DicomAnnotationObject if successful;
null if the
AnnObjectcannot be converted.
Example
This sample does the following:
- Creates a LEAD AnnRectangleObject annotation
- Creates a converter
- Converts to a DicomAnnotationObject annotation
- Converts back to a LEAD AnnObject
- Shows that the original AnnRectangleObject has been changed to a AnnPolygonObject
Visual Basic | Copy Code |
---|
Public Sub DicomAnnotationsUtilities_FromAnnObject()
Dim annObject As AnnRectangleObject = New AnnRectangleObject()
annObject.Pen = New AnnPen(Color.Purple, New AnnLength(5, AnnUnit.Pixel))
annObject.Brush = New AnnSolidBrush(Color.White)
annObject.Bounds = New AnnRectangle(400, 100, 500, 200)
Dim du As DicomAnnotationsUtilities = New DicomAnnotationsUtilities()
du.LayerName = "Test Layer Name"
du.Pen = annObject.Pen
du.Brush = annObject.Brush
Dim dicomAnnotationObject As DicomAnnotationObject = du.FromAnnObject(annObject)
Dim annObjectNew As AnnObject = du.ToAnnObject(dicomAnnotationObject)
Dim msg As String = String.Format("Original type [{0}] New type [{1}]", annObject.GetType(), annObjectNew.GetType())
MessageBox.Show(msg)
End Sub |
C# | Copy Code |
---|
public void DicomAnnotationsUtilities_FromAnnObject() { // Create an AnnRectangleObject AnnRectangleObject annObject = new AnnRectangleObject(); annObject.Pen = new AnnPen(Color.Purple, new AnnLength(5, AnnUnit.Pixel)); annObject.Brush = new AnnSolidBrush(Color.White); annObject.Bounds = new AnnRectangle(400, 100, 500, 200); // Create an instance of the converter, and set some properties DicomAnnotationsUtilities du = new DicomAnnotationsUtilities(); du.LayerName = "Test Layer Name"; du.Pen = annObject.Pen; du.Brush = annObject.Brush; // Convert to a DicomAnnotationObject // Note that there is no DicomAnnotationObject rectangle type, so it is converted to a polyline DicomAnnotationObject dicomAnnotationObject = du.FromAnnObject(annObject); // Convert back to a LEAD AnnObject // Now the LEAD object will be a polyline, even though the original object was a rectangle AnnObject annObjectNew = du.ToAnnObject(dicomAnnotationObject); string msg = string.Format("Original type [{0}] New type [{1}]", annObject.GetType(), annObjectNew.GetType()); MessageBox.Show(msg); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also