Leadtools.Annotations Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
AnnCodecs Class
See Also  Members   Example 
Leadtools.Annotations Namespace : AnnCodecs Class




Provides support for loading and saving objects to annotation files.

Syntax

Visual Basic (Declaration) 
Public Class AnnCodecs 
Visual Basic (Usage)Copy Code
Dim instance As AnnCodecs
C# 
public class AnnCodecs 
Managed Extensions for C++ 
public __gc class AnnCodecs 
C++/CLI 
public ref class AnnCodecs 

Example

This example saves the objects from an existing container to a disk file and loads them back.

Visual BasicCopy Code
Public Sub AnnCodecs_AnnCodecs(ByVal fileName As String)
   ' create a new annotation container
   Dim container As AnnContainer = New AnnContainer()
   ' add a few objects into the container

   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)
   rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
   rectObj.Brush = Nothing
   container.Objects.Add(rectObj)

   Dim lineObj As AnnLineObject = New AnnLineObject()
   lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)
   lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)
   lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))
   container.Objects.Add(lineObj)

   ' create a new AnnCodecs class
   Dim codecs As AnnCodecs = New AnnCodecs()

   ' save this container into a file
   ' save the objects in this container
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite)

   ' get information about the file
   Dim information As AnnCodecsInformation = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' save the objects again (as a second page)
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 2, AnnCodecsSavePageMode.Insert)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' delete the first page
   codecs.DeletePage(fileName, 1)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
End Sub
C#Copy Code
public void AnnCodecs_AnnCodecs(string fileName) 

   // create a new annotation container 
   AnnContainer container = new AnnContainer(); 
   // add a few objects into the container 
 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel); 
   rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel)); 
   rectObj.Brush = null; 
   container.Objects.Add(rectObj); 
 
   AnnLineObject lineObj = new AnnLineObject(); 
   lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel); 
   lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel); 
   lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel)); 
   container.Objects.Add(lineObj); 
 
   // create a new AnnCodecs class 
   AnnCodecs codecs = new AnnCodecs(); 
 
   // save this container into a file 
   // save the objects in this container 
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite); 
 
   // get information about the file 
   AnnCodecsInformation information = new AnnCodecsInformation(); 
   codecs.GetInformation(fileName, information); 
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages)); 
 
   // save the objects again (as a second page) 
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 2, AnnCodecsSavePageMode.Insert); 
 
   // get information about the file 
   information = new AnnCodecsInformation(); 
   codecs.GetInformation(fileName, information); 
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages)); 
 
   // delete the first page 
   codecs.DeletePage(fileName, 1); 
 
   // get information about the file 
   information = new AnnCodecsInformation(); 
   codecs.GetInformation(fileName, information); 
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages)); 
}

Remarks

This class supports loading and saving annotation objects from and to disk files and to memory stream as well as getting information on information objects saved in a disk file or a memory stream.

This class also supports saving and loading multi-page annotation files or streams.

Inheritance Hierarchy

System.Object
   Leadtools.Annotations.AnnCodecs

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

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features