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




container
The AnnContainer containing the objects to be saved.
format
An AnnCodecsTagFormat value that specifies the format used when creating the tag.
Saves the annotation objects in a container to a TIFF tag.

Syntax

Visual Basic (Declaration) 
Public Function SaveToTag( _
   ByVal container As AnnContainer, _
   ByVal format As AnnCodecsTagFormat _
) As RasterTagMetadata
Visual Basic (Usage)Copy Code
Dim instance As AnnCodecs
Dim container As AnnContainer
Dim format As AnnCodecsTagFormat
Dim value As RasterTagMetadata
 
value = instance.SaveToTag(container, format)
Managed Extensions for C++ 
public: RasterTagMetadata SaveToTag( 
   AnnContainer* container,
   AnnCodecsTagFormat format
) 
C++/CLI 
public:
RasterTagMetadata SaveToTag( 
   AnnContainer^ container,
   AnnCodecsTagFormat format
) 

Parameters

container
The AnnContainer containing the objects to be saved.
format
An AnnCodecsTagFormat value that specifies the format used when creating the tag.

Return Value

An RasterTagMetadata object that can be saved into a TIFF file.

Example

Visual BasicCopy Code
Public Sub AnnCodecs_SaveToTag(ByVal tifFileName As String)
   ' first create a container and add a few objects
   Dim container As AnnContainer = New AnnContainer()
   container.Bounds = New AnnRectangle(0, 0, 400, 400, AnnUnit.Pixel)
   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)

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

   ' create a new instance of the AnnCodecs object
   Dim ann As AnnCodecs = New AnnCodecs()

   ' save this container as a TIFF tag
   Dim tag As RasterTagMetadata = ann.SaveToTag(container, AnnCodecsTagFormat.Serialize)
   Dim tagId As Integer = tag.Id

   Dim raster As RasterCodecs = New RasterCodecs()
   raster.WriteTag(tifFileName, 1, tag)

   ' clear the container and the tag
   container.Objects.Clear()
   tag = Nothing

   ' re-load the tag
   tag = raster.ReadTag(tifFileName, 1, tagId)

   ' load the container
   ann.LoadFromTag(tag, container)
End Sub
C#Copy Code
public void AnnCodecs_SaveToTag(string tifFileName) 

   // first create a container and add a few objects 
   AnnContainer container = new AnnContainer(); 
   container.Bounds = new AnnRectangle(0, 0, 400, 400, AnnUnit.Pixel); 
   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); 
 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Bounds = new AnnRectangle(100, 100, 200, 200, AnnUnit.Pixel); 
   rectObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel)); 
   rectObj.Brush = new AnnSolidBrush(Color.White); 
   container.Objects.Add(rectObj); 
 
   // create a new instance of the AnnCodecs object 
   AnnCodecs ann = new AnnCodecs(); 
 
   // save this container as a TIFF tag 
   RasterTagMetadata tag = ann.SaveToTag(container, AnnCodecsTagFormat.Serialize); 
   int tagId = tag.Id; 
 
   RasterCodecs raster = new RasterCodecs(); 
   raster.WriteTag(tifFileName, 1, tag); 
 
   // clear the container and the tag 
   container.Objects.Clear(); 
   tag = null; 
 
   // re-load the tag 
   tag = raster.ReadTag(tifFileName, 1, tagId); 
 
   // load the container 
   ann.LoadFromTag(tag, container); 
}

Remarks

This method will return a tag with ID = .AnnotationTiff (the value 80A4 in hexadecimal).

After calling this method, you can save the RasterTagMetadata object returned into an existing TIFF file by calling the WriteTag method or one of the RasterCodecs.WriteTags(Stream, int, RasterCollection<RasterTagMetadata>) methods.

This method can return null (Nothing in Visual Basic) if you try to save unsupported objects to certain formats (for example, if you try to save an AnnAudioObject to a Wang format).

For more information, refer to Annotation Files.

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