LEADTOOLS Annotations (Leadtools.Annotations assembly)
LEAD Technologies, Inc

SaveToTag Method

Example 





The AnnContainer containing the objects to be saved.
An AnnCodecsTagFormat value that specifies the format used when creating the tag.
Saves the annotation objects in a container to a TIFF tag.
Syntax
'Declaration
 
Public Function SaveToTag( _
   ByVal container As AnnContainer, _
   ByVal format As AnnCodecsTagFormat _
) As RasterTagMetadata
'Usage
 
Dim instance As AnnCodecs
Dim container As AnnContainer
Dim format As AnnCodecsTagFormat
Dim value As RasterTagMetadata
 
value = instance.SaveToTag(container, format)
 function Leadtools.Annotations.AnnCodecs.SaveToTag( 
   container ,
   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 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 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.

Example
 
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
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);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

AnnCodecs Class
AnnCodecs Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.