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



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

Syntax

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

Return Value

A collection of RasterMarkerMetadata used when reading and writing certain file formats (including JPEG).

Example

Visual BasicCopy Code
Public Sub MarkersExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")

   Dim byteData As Byte() = New Byte(0) {}
   byteData(0) = 40
   ' write APP5 (since nobody writes that)
   Dim markerData As RasterMarkerMetadata = New RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData)
   image.Markers.Add(markerData)

   codecs.Options.Save.Markers = True
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_MARKERS.JPG", RasterImageFormat.Jpeg, 0)

   ' load the marker together with the image
   Dim marker As RasterCollection(Of RasterMarkerMetadata) = codecs.ReadMarkers(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_MARKERS.JPG")
   ' look for the APP5 marker, because there might be other markers (like APP0, APP1)
   For Each markerItem As RasterMarkerMetadata In marker
      If markerItem.Id = RasterMarkerMetadata.App0 + 5 Then
         MessageBox.Show("marker Id :" & markerItem.Id.ToString() & " = " & markerItem.GetData().ToString())
      End If
   Next markerItem

   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void MarkersExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); 
 
   byte[] byteData = new byte[1]; 
   byteData[0] = 40; 
   // write APP5 (since nobody writes that) 
   RasterMarkerMetadata markerData = new RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData); 
   image.Markers.Add(markerData); 
 
   codecs.Options.Save.Markers = true; 
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_MARKERS.JPG", RasterImageFormat.Jpeg, 0); 
 
   // load the marker together with the image 
   RasterCollection<RasterMarkerMetadata> marker = codecs.ReadMarkers(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_MARKERS.JPG"); 
   // look for the APP5 marker, because there might be other markers (like APP0, APP1) 
   foreach(RasterMarkerMetadata markerItem in marker) 
      if(markerItem.Id == RasterMarkerMetadata.App0 + 5) 
         MessageBox.Show("marker Id :" + markerItem.Id.ToString() + " = " + markerItem.GetData().ToString()); 
 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

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

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

By setting the CodecsSaveOptions.Markers property to true before calling RasterCodecs.Save, you can save the markers 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.ReadMarkers method to load the markers directly from an existing file and the RasterCodecs.WriteMarkers method to save the markers 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