Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Comments Property
See Also  Example
Leadtools Namespace > RasterImage Class : Comments Property



The collection of comment data used when reading and writing certain file formats (including GIF).

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Comments As RasterCollection(Of RasterCommentMetadata)
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim value As RasterCollection(Of RasterCommentMetadata)
 
value = instance.Comments
C# 
public RasterCollection<RasterCommentMetadata> Comments {get;}
C++/CLI 
public:
property RasterCollection<RasterCommentMetadata>^ Comments {
   RasterCollection<RasterCommentMetadata>^ get();
}

Return Value

A collection of RasterCommentMetadata used when reading and writing certain file formats (including GIF).

Example

Visual BasicCopy Code
Private Sub DisplayComment(ByVal comment As RasterCommentMetadata)
   Select Case comment.DataType
      Case RasterCommentMetadataDataType.Ascii
         MessageBox.Show("Comment of type " & comment.Type.ToString() & " = " & comment.ToAscii())
   End Select
End Sub
Public Sub CommentsExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")

   'Ascii
   Dim commentDataAscii As RasterCommentMetadata = New RasterCommentMetadata()
   ' set the artist comment
   commentDataAscii.Type = RasterCommentMetadataType.Artist
   commentDataAscii.FromAscii("Test String")
   image.Comments.Add(commentDataAscii)

   codecs.Options.Save.Comments = True
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_COMMENTS.TIF", RasterImageFormat.Tif, 0)
   ' load the comment together with the image

   Dim comment As RasterCommentMetadata = codecs.ReadComment(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_COMMENTS.TIF", 1, RasterCommentMetadataType.Artist)
   DisplayComment(comment)

   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
private void DisplayComment(RasterCommentMetadata comment) 

   switch(comment.DataType) 
   { 
      case RasterCommentMetadataDataType.Ascii: 
         MessageBox.Show("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii()); 
         break; 
   } 

public void CommentsExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); 
 
   //Ascii 
   RasterCommentMetadata commentDataAscii = new RasterCommentMetadata(); 
   // set the artist comment 
   commentDataAscii.Type = RasterCommentMetadataType.Artist; 
   commentDataAscii.FromAscii("Test String"); 
   image.Comments.Add(commentDataAscii); 
 
   codecs.Options.Save.Comments = true; 
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_COMMENTS.TIF", RasterImageFormat.Tif, 0); 
   // load the comment together with the image 
 
   RasterCommentMetadata comment = codecs.ReadComment(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_COMMENTS.TIF", 1, RasterCommentMetadataType.Artist); 
   DisplayComment(comment); 
 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

Several formats allow you to store non-image data such as comments, tags, and markers.

You can manipulate the comments of an image by adding/removing RasterCommentMetadata objects to this collection.

By setting the CodecsSaveOptions.Comments property to true before calling RasterCodecs.Save, you can save the comments in this collection when the image is saved into a file.

By setting the CodecsLoadOptions.Markers property to true before calling RasterCodecs.Load, you can load all the markers (if any) into this collection when an image is loaded from a file.

You can use the RasterCodecs.WriteMarkers method to save the markers directly to an existing file.

For more information, refer to Non Image Data.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also