VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Annotation.Formatters Namespace / AnnotationWangFormatter Class
Members Example



In This Topic
    AnnotationWangFormatter Class
    In This Topic
    Serializes annotations to and from WANG format.
    Object Model
    AnnotationWangFormatter ClassResolution Structure
    Syntax
    'Declaration
     
    Public Class AnnotationWangFormatter 
       Inherits AnnotationFormatter
    public class AnnotationWangFormatter : AnnotationFormatter 
    public __gc class AnnotationWangFormatter : public AnnotationFormatter 
    public ref class AnnotationWangFormatter : public AnnotationFormatter 
    Example
    This example 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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also