Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
EnumTags Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : EnumTags Method




fileName
A String containing the input file name.
pageNumber
1-based index of the page from which to enumerate the tags.
Enumerates all the tags in a file.

Syntax

Visual Basic (Declaration) 
Public Sub EnumTags( _
   ByVal fileName As String, _
   ByVal pageNumber As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim fileName As String
Dim pageNumber As Integer
 
instance.EnumTags(fileName, pageNumber)
C# 
public void EnumTags( 
   string fileName,
   int pageNumber
)
Managed Extensions for C++ 
public: void EnumTags( 
   string* fileName,
   int pageNumber
) 
C++/CLI 
public:
void EnumTags( 
   String^ fileName,
   int pageNumber
) 

Parameters

fileName
A String containing the input file name.
pageNumber
1-based index of the page from which to enumerate the tags.

Example

Visual BasicCopy Code
RasterCodecs.EnumTags
      Private tagsFileName As String
      Private myTags As RasterCollection(Of RasterTagMetadata)
      Private Sub EnumTagsExample(ByVal srcFileName As String, ByVal destFileName As String)
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()

         tagsFileName = srcFileName
         myTags = New RasterCollection(Of RasterTagMetadata)()

         AddHandler codecs.TagFound, AddressOf codecs_TagFound
         codecs.EnumTags(srcFileName, 1)
         RemoveHandler codecs.TagFound, AddressOf codecs_TagFound

         ' We read all the tags now, save them to the file
         Console.WriteLine("{0} tags read, saving them to the destination file", myTags.Count)
         codecs.WriteTags(destFileName, 1, myTags)

         ' Clean up
         codecs.Dispose()
         RasterCodecs.Shutdown()
      End Sub

      Private Sub codecs_TagFound(ByVal sender As Object, ByVal e As CodecsEnumTagsEventArgs)
         Console.WriteLine("Tag: Id={0}, Count={1}, Type={2}", e.Id, e.Count, e.MetadataType)

         ' Read this tag from the file and add it to our collection
         Dim codecs As RasterCodecs = TryCast(sender, RasterCodecs)
         Dim tag As RasterTagMetadata = codecs.ReadTag(tagsFileName, 1, e.Id)
         myTags.Add(tag)
      End Sub
C#Copy Code
RasterCodecs.EnumTags 
      string tagsFileName; 
      RasterCollection<RasterTagMetadata> myTags; 
      void EnumTagsExample(string srcFileName, string destFileName) 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         tagsFileName = srcFileName; 
         myTags = new RasterCollection<RasterTagMetadata>(); 
 
         codecs.TagFound += new EventHandler<CodecsEnumTagsEventArgs>(codecs_TagFound); 
         codecs.EnumTags(srcFileName, 1); 
         codecs.TagFound -= new EventHandler<CodecsEnumTagsEventArgs>(codecs_TagFound); 
 
         // We read all the tags now, save them to the file 
         Console.WriteLine("{0} tags read, saving them to the destination file", myTags.Count); 
         codecs.WriteTags(destFileName, 1, myTags); 
 
         // Clean up 
         codecs.Dispose(); 
         RasterCodecs.Shutdown(); 
      } 
 
      void codecs_TagFound(object sender, CodecsEnumTagsEventArgs e) 
      { 
         Console.WriteLine("Tag: Id={0}, Count={1}, Type={2}", e.Id, e.Count, e.MetadataType); 
 
         // Read this tag from the file and add it to our collection 
         RasterCodecs codecs = sender as RasterCodecs; 
         RasterTagMetadata tag = codecs.ReadTag(tagsFileName, 1, e.Id); 
         myTags.Add(tag); 
      }

Remarks

This method will fire the TagFound event for each tag found in the file.

Currently, only TIFF and Exif files contain tags.

For multipage TIFF files, you can enumerate the tags from a particular page. Specify the page number whose tags to enumerate.

This method enumerates the standard TIFF tags and the user tags. Standard TIFF tags are less than 32767. User TIFF tags are usually between 32768 and 65535.

To read a tag value, use ReadTag.

For general information about TIFF tags, refer to Implementing TIFF Comments and Tags.

Do not attempt to use DeleteTag to delete tags from inside the TagFound event. If you want to delete tags that you enumerate, use this event to add the tags to a list. Upon returning from EnumTags, you can delete all the tags from the list.

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