LEADTOOLS Image File Support (Leadtools.Codecs assembly)

WriteMarker(String,Int32,RasterMarkerMetadata) Method

Show in webframe
Example 







A System.String that contains the file name.
1-based index of the page at which to write the marker.
A Leadtools.RasterMarkerMetadata object that contains the marker data.
Writes a marker to an existing file.
Syntax
public void WriteMarker( 
   string fileName,
   int pageNumber,
   RasterMarkerMetadata marker
)
'Declaration
 
Public Overloads Sub WriteMarker( _
   ByVal fileName As String, _
   ByVal pageNumber As Integer, _
   ByVal marker As RasterMarkerMetadata _
) 
'Usage
 
Dim instance As RasterCodecs
Dim fileName As String
Dim pageNumber As Integer
Dim marker As RasterMarkerMetadata
 
instance.WriteMarker(fileName, pageNumber, marker)
public void WriteMarker( 
   string fileName,
   int pageNumber,
   RasterMarkerMetadata marker
)

            

            
 function Leadtools.Codecs.RasterCodecs.WriteMarker(String,Int32,RasterMarkerMetadata)( 
   fileName ,
   pageNumber ,
   marker 
)
public:
void WriteMarker( 
   String^ fileName,
   int pageNumber,
   RasterMarkerMetadata^ marker
) 

Parameters

fileName
A System.String that contains the file name.
pageNumber
1-based index of the page at which to write the marker.
marker
A Leadtools.RasterMarkerMetadata object that contains the marker data.
Remarks

For Exif files, this metadata collection will contain all the Exif and GPS comments, stored in APP1. It will also contain the audio information stored in APP2.

When you add or remove tags, the tags array at the end of the file is re-written. When you modify existing tags, the new tag value is added to the file and the IFD is modified as necessary. In all of these cases, there is no image recompression.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing

Private Sub MarkersExample(ByVal srcFileName As String, ByVal destFileName As String)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load the source image with markers
   Console.WriteLine("Loading the source image with all markers")
   codecs.Options.Load.Markers = True
   Dim srcImage As RasterImage = codecs.Load(srcFileName)

   ' Show the markers loaded
   Console.WriteLine("These markers were loaded:")
   For Each marker As RasterMarkerMetadata In srcImage.Markers
      Dim data As Byte() = marker.GetData()
      Console.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length)
   Next marker

   ' Create the destination image
   Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 320, 20, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)

   ' Save this as JPEG
   codecs.Save(destImage, destFileName, RasterImageFormat.Jpeg, 24)

   ' Write the markers from the source image to this destination image
   Console.WriteLine("Writing the markers to the destination file")
   codecs.WriteMarkers(destFileName, 1, srcImage.Markers)

   srcImage.Dispose()
   destImage.Dispose()

   ' Re-load the destination image with markers
   Console.WriteLine("Loading the destination image with all markers")
   codecs.Options.Load.Markers = True
   destImage = codecs.Load(destFileName)

   ' Show the markers loaded
   Console.WriteLine("These markers were loaded:")
   For Each marker As RasterMarkerMetadata In destImage.Markers
      Dim data As Byte() = marker.GetData()
      Console.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length)
   Next marker

   destImage.Dispose()

   ' Clean up
   codecs.Dispose()
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

void MarkersExample(string srcFileName, string destFileName)
{
   RasterCodecs codecs = new RasterCodecs();
   // Load the source image with markers
   Console.WriteLine("Loading the source image with all markers");
   codecs.Options.Load.Markers = true;
   RasterImage srcImage = codecs.Load(srcFileName);

   // Show the markers loaded
   Console.WriteLine("These markers were loaded:");
   foreach (RasterMarkerMetadata marker in srcImage.Markers)
   {
      byte[] data = marker.GetData();
      Console.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   // Create the destination image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      320,
      20,
      24,
      RasterByteOrder.Bgr,
      RasterViewPerspective.TopLeft,
      null,
      IntPtr.Zero,
      0);

   // Save this as JPEG
   codecs.Save(destImage, destFileName, RasterImageFormat.Jpeg, 24);

   // Write the markers from the source image to this destination image
   Console.WriteLine("Writing the markers to the destination file");
   codecs.WriteMarkers(destFileName, 1, srcImage.Markers);

   srcImage.Dispose();
   destImage.Dispose();

   // Re-load the destination image with markers
   Console.WriteLine("Loading the destination image with all markers");
   codecs.Options.Load.Markers = true;
   destImage = codecs.Load(destFileName);

   // Show the markers loaded
   Console.WriteLine("These markers were loaded:");
   foreach (RasterMarkerMetadata marker in destImage.Markers)
   {
      byte[] data = marker.GetData();
      Console.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   destImage.Dispose();

   // Clean up
   codecs.Dispose();
}
RasterCodecsExamples.prototype.MarkersExample = function ( ) 
{
   Tools.SetLicense ( ) ;
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var srcFileName = "Assets\\WithAudio.jpg";
         var destFileName = "Markers.jpg";
         var codecs = new RasterCodecs();
         var srcImage;
         var destImage;
         var loadFile;
         var saveFile;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFileX) {
            loadFile = loadFileX;
            return Tools.AppLocalFolder().createFileAsync(destFileName)
         })
         .then(function (saveFileX) {
            saveFile = saveFileX;
            // Load the source image with markers
            console.info("Loading the source image with all markers");
            codecs.options.load.markers = true;
            return codecs.loadAsync(LeadStreamFactory.create(loadFile))
         })
         .then(function (img) {
            srcImage = img;

            // Show the markers loaded
            console.info("These markers were loaded:");
            for (var i = 0; i < srcImage.markers.length; i++) {
               var marker = srcImage.markers[i];
               var data = marker.getData();
               console.info(marker.id, " , DataSize:", data.length);
            }

            // Create the destination image
            destImage = new RasterImage(
              RasterMemoryFlags.conventional,
              320,
              20,
              24,
              RasterByteOrder.bgr,
              RasterViewPerspective.topLeft,
              null);

            // Save this as JPEG
            return codecs.saveAsync(destImage, LeadStreamFactory.create(saveFile), RasterImageFormat.jpeg, 24)
         })
         .then(function () {

            // Write the markers from the source image to this destination image
            console.info("Writing the markers to the destination file");
            //srcImage.Markers.
            var markers = new Array(srcImage.markers.length);
            for (var i = 0; i < markers.length; i++)
            {
               markers[i] = srcImage.markers[i];
            }

            return codecs.writeMarkersAsync(LeadStreamFactory.create(saveFile), 1, markers)
         })
         .then(function () {

            srcImage.close();
            destImage.close();

            // Re-load the destination image with markers
            console.info("Loading the destination image with all markers");
            codecs.options.load.markers = true;
            return codecs.loadAsync(LeadStreamFactory.create(saveFile))
         })
         .then(function (img) {
            destImage = img;

            // Show the markers loaded
            console.info("These markers were loaded:");
            for (var i = 0; i < destImage.markers.length; i++) {
               var marker = destImage.markers[i];
               var data = marker.getData();
               console.info(marker.id, " , DataSize:", data.length);
            }

            destImage.close();

            // Clean up
            codecs.close();
         });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

async Task MarkersExample(string srcFileName, string destFileName)
{
   RasterCodecs codecs = new RasterCodecs();
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);

   // Load the source image with markers
   Debug.WriteLine("Loading the source image with all markers");
   codecs.Options.Load.Markers = true;
   RasterImage srcImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Show the markers loaded
   Debug.WriteLine("These markers were loaded:");
   foreach (RasterMarkerMetadata marker in srcImage.Markers)
   {
      byte[] data = marker.GetData();
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   // Create the destination image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      320,
      20,
      24,
      RasterByteOrder.Bgr,
      RasterViewPerspective.TopLeft,
      null);

   // Save this as JPEG
   await codecs.SaveAsync(destImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.Jpeg, 24);

   // Write the markers from the source image to this destination image
   Debug.WriteLine("Writing the markers to the destination file");
   //srcImage.Markers.
   IReadOnlyList<RasterMarkerMetadata> readOnlyMarkers = new ReadOnlyCollection<RasterMarkerMetadata>(srcImage.Markers);
   await codecs.WriteMarkersAsync(LeadStreamFactory.Create(saveFile), 1, readOnlyMarkers);

   srcImage.Dispose();
   destImage.Dispose();

   // Re-load the destination image with markers
   Debug.WriteLine("Loading the destination image with all markers");
   codecs.Options.Load.Markers = true;
   destImage = await codecs.LoadAsync(LeadStreamFactory.Create(saveFile));

   // Show the markers loaded
   Debug.WriteLine("These markers were loaded:");
   foreach (RasterMarkerMetadata marker in destImage.Markers)
   {
      byte[] data = marker.GetData();
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   destImage.Dispose();

   // Clean up
   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Windows.Media;

void MarkersExample(Stream inStreamExif, Stream outStreamJpg)
{
   RasterCodecs codecs = new RasterCodecs();
   // Load the source image with markers
   Debug.WriteLine("Loading the source image with all markers");
   codecs.Options.Load.Markers = true;
   RasterImage srcImage = codecs.Load(inStreamExif);

   // Show the markers loaded
   Debug.WriteLine("These markers were loaded:");
   foreach(RasterMarkerMetadata marker in srcImage.Markers)
   {
      byte[] data = marker.GetData();
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   // Create the destination image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      320,
      20,
      24,
      RasterByteOrder.Bgr,
      RasterViewPerspective.TopLeft,
      null,
      null,
      0);

   // Save this as JPEG
   codecs.Save(destImage, outStreamJpg, RasterImageFormat.Jpeg, 24);

   // Write the markers from the source image to this destination image
   Debug.WriteLine("Writing the markers to the destination file");
   codecs.WriteMarkers(outStreamJpg, 1, srcImage.Markers);

   srcImage.Dispose();
   destImage.Dispose();

   // Re-load the destination image with markers
   Debug.WriteLine("Loading the destination image with all markers");
   codecs.Options.Load.Markers = true;
   destImage = codecs.Load(outStreamJpg);

   // Show the markers loaded
   Debug.WriteLine("These markers were loaded:");
   foreach(RasterMarkerMetadata marker in destImage.Markers)
   {
      byte[] data = marker.GetData();
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length);
   }

   destImage.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Private Sub MarkersExample(ByVal inStreamExif As Stream, ByVal outStreamJpg As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load the source image with markers
   Debug.WriteLine("Loading the source image with all markers")
   codecs.Options.Load.Markers = True
   Dim srcImage As RasterImage = codecs.Load(inStreamExif)

   ' Show the markers loaded
   Debug.WriteLine("These markers were loaded:")
   For Each marker As RasterMarkerMetadata In srcImage.Markers
      Dim data As Byte() = marker.GetData()
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length)
   Next marker

   ' Create the destination image
   Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 320, 20, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, Nothing, 0)

   ' Save this as JPEG
   codecs.Save(destImage, outStreamJpg, RasterImageFormat.Jpeg, 24)

   ' Write the markers from the source image to this destination image
   Debug.WriteLine("Writing the markers to the destination file")
   codecs.WriteMarkers(outStreamJpg, 1, srcImage.Markers)

   srcImage.Dispose()
   destImage.Dispose()

   ' Re-load the destination image with markers
   Debug.WriteLine("Loading the destination image with all markers")
   codecs.Options.Load.Markers = True
   destImage = codecs.Load(outStreamJpg)

   ' Show the markers loaded
   Debug.WriteLine("These markers were loaded:")
   For Each marker As RasterMarkerMetadata In destImage.Markers
      Dim data As Byte() = marker.GetData()
      Debug.WriteLine(" {0}, DataSize:{1}", marker.Id, data.Length)
   Next marker

   destImage.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.