The collection of tag data used when reading and writing certain file formats (including TIFF).
Syntax
Return Value
A collection of
RasterTagMetadata used when reading and writing certain file formats (including TIFF).
Example
Visual Basic | Copy Code |
---|
Private Sub DisplayTag(ByVal tag As RasterTagMetadata)
Select Case tag.DataType
Case RasterTagMetadataDataType.Ascii
MessageBox.Show("Tag " & tag.Id.ToString() & " = " & tag.ToAscii())
Case RasterTagMetadataDataType.Byte
MessageBox.Show("Tag " & tag.Id.ToString() & " = " & tag.ToByte()(0).ToString())
End Select
End Sub
Public Sub TagsExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")
Dim tagDataAscii As RasterTagMetadata = New RasterTagMetadata()
tagDataAscii.Id = &H8000
tagDataAscii.DataType = RasterTagMetadataDataType.Ascii
tagDataAscii.FromAscii("Test String")
image.Tags.Add(tagDataAscii)
Dim tagDataByte As RasterTagMetadata = tagDataAscii.Clone()
tagDataAscii.Id = &H8001
tagDataByte.DataType = RasterTagMetadataDataType.Byte
Dim byteArray As Byte() = New Byte(0) {}
byteArray(0) = 10
tagDataByte.FromByte(byteArray)
image.Tags.Add(tagDataByte)
codecs.Options.Save.Tags = True
codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", RasterImageFormat.Tif, 0)
Dim tag As RasterTagMetadata = codecs.ReadTag(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", 1, &H8000)
DisplayTag(tag)
tag = codecs.ReadTag(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", 1, &H8001)
DisplayTag(tag)
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
private void DisplayTag(RasterTagMetadata tag) { switch(tag.DataType) { case RasterTagMetadataDataType.Ascii: MessageBox.Show("Tag " + tag.Id.ToString() + " = " + tag.ToAscii()); break; case RasterTagMetadataDataType.Byte: MessageBox.Show("Tag " + tag.Id.ToString() + " = " + tag.ToByte()[0].ToString()); break; } } public void TagsExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); //Ascii RasterTagMetadata tagDataAscii = new RasterTagMetadata(); // set the Copyright tag tagDataAscii.Id = 0x8000; tagDataAscii.DataType = RasterTagMetadataDataType.Ascii; tagDataAscii.FromAscii("Test String"); image.Tags.Add(tagDataAscii); //Byte RasterTagMetadata tagDataByte = tagDataAscii.Clone(); tagDataAscii.Id = 0x8001; tagDataByte.DataType = RasterTagMetadataDataType.Byte; byte[] byteArray = new byte[1]; byteArray[0] = 10; tagDataByte.FromByte(byteArray); image.Tags.Add(tagDataByte); codecs.Options.Save.Tags = true; codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", RasterImageFormat.Tif, 0); // load the tags together with the image RasterTagMetadata tag = codecs.ReadTag(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", 1, 0x8000); DisplayTag(tag); tag = codecs.ReadTag(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_TAGS.TIF", 1, 0x8001); DisplayTag(tag); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also