Writes a marker to an existing file.
Overload List
Example
Visual Basic | Copy Code |
---|
RasterCodecs.Markers
Private Sub MarkersExample(ByVal srcFileName As String, ByVal destFileName As String)
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Console.WriteLine("Loading the source image with all markers")
codecs.Options.Load.Markers = True
Dim srcImage As RasterImage = codecs.Load(srcFileName)
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
Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 320, 20, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)
codecs.Save(destImage, destFileName, RasterImageFormat.Jpeg, 24)
Console.WriteLine("Writing the markers to the destination file")
codecs.WriteMarkers(destFileName, 1, srcImage.Markers)
srcImage.Dispose()
destImage.Dispose()
Console.WriteLine("Loading the destination image with all markers")
codecs.Options.Load.Markers = True
destImage = codecs.Load(destFileName)
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()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
RasterCodecs.Markers void MarkersExample(string srcFileName, string destFileName) { RasterCodecs.Startup(); 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(); RasterCodecs.Shutdown(); } |
Remarks
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