Gets or sets a value that indicate whether any tags found in the file should be automatically loaded.
Syntax
Visual Basic (Declaration) | |
---|
Public Property Tags As Boolean |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As CodecsLoadOptions
Dim value As Boolean
instance.Tags = value
value = instance.Tags
|
C# | |
---|
public bool Tags {get; set;} |
C++/CLI | |
---|
public:
property bool Tags {
bool get();
void set (bool value);
} |
Return Value
true to automatically load any tags found in the file; otherwise it is
false.
Example
This example will browse to a file and load it along with any tags, geo-keys and comments found.
Visual Basic | Copy Code |
---|
Public Sub MetadataAutoLoadExample()
Dim imageFileName As String
Using dlg As New OpenFileDialog()
dlg.Title = "Browse to file to load its meta data"
dlg.Filter = "All Files|*.*"
dlg.InitialDirectory = "C:\Users\Public\Documents\LEADTOOLS Images"
If dlg.ShowDialog() = DialogResult.OK Then
imageFileName = dlg.FileName
Else
Return
End If
End Using
RasterCodecs.Startup()
Using codecs As New RasterCodecs()
Dim loadOptions As CodecsLoadOptions = codecs.Options.Load
loadOptions.Markers = False
loadOptions.Tags = True
loadOptions.Comments = True
loadOptions.GeoKeys = True
Using image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
Dim txtFileName As String = Path.Combine( _
Path.GetDirectoryName(imageFileName), _
Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt")
Using writer As StreamWriter = File.CreateText(txtFileName)
ShowTags(writer, "Tags", image.Tags)
ShowComments(writer, image.Comments)
ShowTags(writer, "GeoKeys", image.GeoKeys)
End Using
System.Diagnostics.Process.Start(txtFileName)
End Using
End Using
RasterCodecs.Shutdown()
End Sub
Private Shared Sub ShowTags(ByVal writer As StreamWriter, ByVal name As String, ByVal tags As RasterCollection(Of RasterTagMetadata))
writer.WriteLine("{0}:", name)
For Each tag As RasterTagMetadata In tags
writer.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length)
Next
writer.WriteLine()
End Sub
Private Shared Sub ShowComments(ByVal writer As StreamWriter, ByVal comments As RasterCollection(Of RasterCommentMetadata))
writer.WriteLine("Comments:")
For Each comment As RasterCommentMetadata In comments
writer.WriteLine("Type: 0x{0}, data length: {1}", comment.Type, comment.GetData().Length)
Next
writer.WriteLine()
End Sub |
C# | Copy Code |
---|
public void MetadataAutoLoadExample() { // Prompt the user for an image file string imageFileName; using(OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Browse to file to load its meta data"; dlg.Filter = "All Files|*.*"; dlg.InitialDirectory = @"C:\Users\Public\Documents\LEADTOOLS Images"; if(dlg.ShowDialog() == DialogResult.OK) imageFileName = dlg.FileName; else return; } // Initialize LEADTOOLS RasterCodecs.Startup(); using(RasterCodecs codecs = new RasterCodecs()) { CodecsLoadOptions loadOptions = codecs.Options.Load; // Make sure auto-loading of markers is turned off, otherwise, // markers take precedence over loading the other metadata loadOptions.Markers = false; // Automatically load any tags, comments and geokeys found in this file loadOptions.Tags = true; loadOptions.Comments = true; loadOptions.GeoKeys = true; // Now load the image using(RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) { string txtFileName = Path.Combine( Path.GetDirectoryName(imageFileName), Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt"); using(StreamWriter writer = File.CreateText(txtFileName)) { // Show its tags ShowTags(writer, "Tags", image.Tags); // Show its comments ShowComments(writer, image.Comments); // Show its geo keys (tags and geokeys use the same data type) ShowTags(writer, "GeoKeys", image.GeoKeys); } // Show the text file we created System.Diagnostics.Process.Start(txtFileName); } } RasterCodecs.Shutdown(); } private static void ShowTags(StreamWriter writer, string name, RasterCollection<RasterTagMetadata> tags) { writer.WriteLine("{0}:", name); foreach(RasterTagMetadata tag in tags) { writer.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length); } writer.WriteLine(); } private static void ShowComments(StreamWriter writer, RasterCollection<RasterCommentMetadata> comments) { writer.WriteLine("Comments:"); foreach(RasterCommentMetadata comment in comments) { writer.WriteLine("Type: 0x{0}, data length: {1}", comment.Type, comment.GetData().Length); } writer.WriteLine(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also