The SaveToTag Method is available in LEADTOOLS Document and Medical Imaging toolkits.
- container
- The AnnContainer containing the objects to be saved.
- format
- An AnnCodecsTagFormat value that specifies the format used when creating the tag.
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) |
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 Leadtools.RasterTagMetadata object that can be saved into a TIFF file.Visual Basic | Copy 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); } |
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.
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7