AnnotationWangFormatter Class
In This Topic
Serializes annotations to and from WANG format.
Object Model
Syntax
Example
Here is an example that shows how to save an annotation collection of image to the file using WANG formatter:
' Create the image collection and add images to collection.
Dim imageCollection As New Vintasoft.Imaging.ImageCollection()
imageCollection.Add("D:\Images\AutoContrast.jpg")
imageCollection.Add("D:\Images\AutoColors.jpg")
' Create annotation controller associated with image collection.
Dim annotationDataController As New Vintasoft.Imaging.Annotation.AnnotationDataController(imageCollection)
' Create a rectangle annotation.
Dim rectangleAnnotationData As New Vintasoft.Imaging.Annotation.RectangleAnnotationData()
rectangleAnnotationData.Location = New System.Drawing.PointF(32, 27)
rectangleAnnotationData.Size = New System.Drawing.SizeF(38, 35)
' Add the rectangle annotation to the annotation collection of first image.
annotationDataController(0).Add(rectangleAnnotationData)
' Create a line annotation.
Dim lineAnnotationData As New Vintasoft.Imaging.Annotation.LineAnnotationData()
lineAnnotationData.Location = New System.Drawing.PointF(17, 66)
lineAnnotationData.EndPoint = New System.Drawing.PointF(51, 50)
' Add the line annotation to the annotation collection of first image.
annotationDataController(0).Add(lineAnnotationData)
' Create a WANG formmater.
Dim wangFormatter As New Vintasoft.Imaging.Annotation.Formatters.AnnotationWangFormatter(imageCollection(0).Resolution)
' Create a file where WANG packet will be saved.
Using file As New System.IO.FileStream("D:\Annotations.wng", System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite)
' Get a reference to the annotation collection of first image.
Dim annotationDataCollection As Vintasoft.Imaging.Annotation.AnnotationDataCollection = annotationDataController(0)
' Save annotation collection to the file using WANG formatter.
wangFormatter.Serialize(file, annotationDataCollection)
End Using
// Create the image collection and add images to collection.
Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection();
imageCollection.Add(@"D:\Images\AutoContrast.jpg");
imageCollection.Add(@"D:\Images\AutoColors.jpg");
// Create annotation controller associated with image collection.
Vintasoft.Imaging.Annotation.AnnotationDataController annotationDataController =
new Vintasoft.Imaging.Annotation.AnnotationDataController(imageCollection);
// Create a rectangle annotation.
Vintasoft.Imaging.Annotation.RectangleAnnotationData rectangleAnnotationData =
new Vintasoft.Imaging.Annotation.RectangleAnnotationData();
rectangleAnnotationData.Location = new System.Drawing.PointF(32, 27);
rectangleAnnotationData.Size = new System.Drawing.SizeF(38, 35);
// Add the rectangle annotation to the annotation collection of first image.
annotationDataController[0].Add(rectangleAnnotationData);
// Create a line annotation.
Vintasoft.Imaging.Annotation.LineAnnotationData lineAnnotationData =
new Vintasoft.Imaging.Annotation.LineAnnotationData();
lineAnnotationData.Location = new System.Drawing.PointF(17, 66);
lineAnnotationData.EndPoint = new System.Drawing.PointF(51, 50);
// Add the line annotation to the annotation collection of first image.
annotationDataController[0].Add(lineAnnotationData);
// Create a WANG formmater.
Vintasoft.Imaging.Annotation.Formatters.AnnotationWangFormatter wangFormatter =
new Vintasoft.Imaging.Annotation.Formatters.AnnotationWangFormatter(imageCollection[0].Resolution);
// Create a file where WANG packet will be saved.
using (System.IO.FileStream file = new System.IO.FileStream(@"D:\Annotations.wng",
System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite))
{
// Get a reference to the annotation collection of first image.
Vintasoft.Imaging.Annotation.AnnotationDataCollection annotationDataCollection = annotationDataController[0];
// Save annotation collection to the file using WANG formatter.
wangFormatter.Serialize(file, annotationDataCollection);
}
Inheritance Hierarchy
System.Object
 Vintasoft.Imaging.Annotation.Formatters.AnnotationFormatter
   Vintasoft.Imaging.Annotation.Formatters.AnnotationWangFormatter
Requirements
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also