Saves the annotation objects in a container to a TIFF tag.
Syntax
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 Basic | Copy Code |
---|
Public Sub AnnCodecs_SaveToTag(ByVal tifFileName As String)
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)
Dim ann As AnnCodecs = New AnnCodecs()
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)
container.Objects.Clear()
tag = Nothing
tag = raster.ReadTag(tifFileName, 1, tagId)
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
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