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:
<list type="number">
<item><description>Creates a LEAD AnnRectangleObject annotation</description></item>
<item><description>Creates a converter</description></item>
<item><description>Converts to a DicomAnnotationObject annotation</description></item>
<item><description>Converts back to a LEAD AnnObject></item>
<item><description>Shows that the original AnnRectangleObject has been changed to a AnnPolygonObject</description></item>
</list>
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 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also