←Select platform

SaveToTag Method

Summary

Saves the annotation objects in a container to a TIFF tag.

Syntax

C#
VB
C++

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 Leadtools.RasterTagMetadata object that can be saved into a TIFF file.

Remarks

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

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

This method can return null (Nothing in VB) 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 (Deprecated).

Example

C#
VB
using Leadtools; 
using Leadtools.Annotations; 
using Leadtools.Codecs; 
using Leadtools.WinForms; 
 
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); 
} 
Imports Leadtools 
Imports Leadtools.Annotations 
Imports Leadtools.Codecs 
Imports Leadtools.WinForms 
 
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 

Requirements

Target Platforms

See Also

Reference

AnnCodecs Class

AnnCodecs Members

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations Assembly