Extends the RasterMetadata class to provide functionality for dealing with marker metadata stored within various image file formats.
[SerializableAttribute()]public class RasterMarkerMetadata : Leadtools.RasterMetadata
<SerializableAttribute()>Public Class RasterMarkerMetadataInherits Leadtools.RasterMetadata
public sealed class RasterMarkerMetadata : Leadtools.RasterMetadata @interface LTRasterMarkerMetadata : LTRasterMetadata public class RasterMarkerMetadata extends RasterMetadata implements Serializable function Leadtools.RasterMarkerMetadata() [SerializableAttribute()]public ref class RasterMarkerMetadata : public Leadtools.RasterMetadata
JPEG files contain metadata information in user-defined markers.
The user-defined markers are in the range 0xE0 to 0xFE. These markers can have a maximum size of 0xFFFD, or 65533 bytes.
The markers below 0xE0 are reserved for the encoding of the image and inserting a reserved marker can make a file invalid. Therefore, you should not use reserved markers unless you are well acquainted with markers and image encoding in JPEG files.
TIFF files do not contain markers, however, LEADTOOLS provides a "workaround" for transferring Exif comments from JPEG files to TIFF files, and vice versa. The Exif metadata information from a TIFF file will be loaded as an APP1 marker. Therefore, you can load Exif metadata from an uncompressed file and store it in a compressed Exif file.
You can also take metadata information from a compressed Exif file and store it in an uncompressed Exif file. Please note however, that some information cannot be stored inside uncompressed Exif files. For example, audio data is stored in APP2 markers and there is no built-in support for saving APP2 markers in TIFF files. However, you can still save the audio data yourself, using a custom tag.
This example will write different markers to an existing TIF file then read them as a test.
using Leadtools;using Leadtools.Codecs;using LeadtoolsExamples.Common;public void RasterMarkerMetadataExample(){RasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");string destFileName = Path.Combine(ImagesPath.Path, "Image1_markers.tif");// Load the imageRasterImage image = codecs.Load(srcFileName);codecs.Save(image, destFileName, RasterImageFormat.ExifJpeg, 24);image.Dispose();// write a marker to the fileRasterMarkerMetadata markerWrite = new RasterMarkerMetadata();byte[] data = new byte[100];for (int i = 0; i < data.Length; i++)data[i] = (byte)(i + 1);markerWrite.Id = 0xE0;markerWrite.SetData(data);Console.WriteLine("Writing the marker");codecs.WriteMarker(destFileName, 1, markerWrite);// read the markers from the file and check for oursRasterCollection<RasterMarkerMetadata> markers = codecs.ReadMarkers(destFileName);RasterMarkerMetadata markerRead = null;for (int i = 0; i < markers.Count && markerRead == null; i++){if (markers[i].Id == markerWrite.Id)markerRead = markers[i];}Assert.IsTrue(markerRead.Id == markerWrite.Id);byte[] dataRead = markerRead.GetData();byte[] dataWrite = markerWrite.GetData();Assert.IsTrue(dataRead.Length == dataWrite.Length);for (int i = 0; i < dataRead.Length; i++)Assert.IsTrue(dataRead[i] == dataWrite[i]);codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsPublic Sub RasterMarkerMetadataExample()Dim codecs As RasterCodecs = New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_markers.tif")' Load the imageDim image As RasterImage = codecs.Load(srcFileName)codecs.Save(image, destFileName, RasterImageFormat.ExifJpeg, 24)image.Dispose()' write a marker to the fileDim markerWrite As RasterMarkerMetadata = New RasterMarkerMetadata()Dim data As Byte() = New Byte(99) {}Dim i As Integer = 0Do While i < data.Lengthdata(i) = CByte(i + 1)i += 1LoopmarkerWrite.Id = &HE0markerWrite.SetData(data)Console.WriteLine("Writing the marker")codecs.WriteMarker(destFileName, 1, markerWrite)' read the markers from the file and check for oursDim markers As RasterCollection(Of RasterMarkerMetadata) = codecs.ReadMarkers(destFileName)Dim markerRead As RasterMarkerMetadata = Nothingi = 0Do While i < markers.Count AndAlso markerRead Is NothingIf markers(i).Id = markerWrite.Id ThenmarkerRead = markers(i)End Ifi += 1LoopDebug.Assert(markerRead.Id = markerWrite.Id)Dim dataRead As Byte() = markerRead.GetData()Dim dataWrite As Byte() = markerWrite.GetData()Debug.Assert(dataRead.Length = dataWrite.Length)i = 0Do While i < dataRead.LengthDebug.Assert(dataRead(i) = dataWrite(i))i += 1LoopEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;public void RasterMarkerMetadataExample(RasterImage image, Stream destStream){RasterCodecs codecs = new RasterCodecs();codecs.Save(image, destStream, RasterImageFormat.ExifJpeg, 24);image.Dispose();// write a marker to the fileRasterMarkerMetadata markerWrite = new RasterMarkerMetadata();byte[] data = new byte[100];for (int i = 0; i < data.Length; i++)data[i] = (byte)(i + 1);markerWrite.Id = 0xE0;markerWrite.SetData(data);Console.WriteLine("Writing the marker");codecs.WriteMarker(destStream, 1, markerWrite);// read the markers from the file and check for oursRasterCollection<RasterMarkerMetadata> markers = codecs.ReadMarkers(destStream);RasterMarkerMetadata markerRead = null;for (int i = 0; i < markers.Count && markerRead == null; i++){if (markers[i].Id == markerWrite.Id)markerRead = markers[i];}Debug.Assert(markerRead.Id == markerWrite.Id);byte[] dataRead = markerRead.GetData();byte[] dataWrite = markerWrite.GetData();Debug.Assert(dataRead.Length == dataWrite.Length);for (int i = 0; i < dataRead.Length; i++)Debug.Assert(dataRead[i] == dataWrite[i]);}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingPublic Sub RasterMarkerMetadataExample(ByVal image As RasterImage, ByVal destStream As Stream)Dim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, destStream, RasterImageFormat.ExifJpeg, 24)image.Dispose()' write a marker to the fileDim markerWrite As RasterMarkerMetadata = New RasterMarkerMetadata()Dim data As Byte() = New Byte(99) {}Dim i As Integer = 0Do While i < data.Lengthdata(i) = CByte(i + 1)i += 1LoopmarkerWrite.Id = &HE0markerWrite.SetData(data)Console.WriteLine("Writing the marker")codecs.WriteMarker(destStream, 1, markerWrite)' read the markers from the file and check for oursDim markers As RasterCollection(Of RasterMarkerMetadata) = codecs.ReadMarkers(destStream)Dim markerRead As RasterMarkerMetadata = Nothingi = 0Do While i < markers.Count AndAlso markerRead Is NothingIf markers(i).Id = markerWrite.Id ThenmarkerRead = markers(i)End Ifi += 1LoopDebug.Assert(markerRead.Id = markerWrite.Id)Dim dataRead As Byte() = markerRead.GetData()Dim dataWrite As Byte() = markerWrite.GetData()Debug.Assert(dataRead.Length = dataWrite.Length)i = 0Do While i < dataRead.LengthDebug.Assert(dataRead(i) = dataWrite(i))i += 1LoopEnd Sub
|
Products |
Support |
Feedback: RasterMarkerMetadata Class - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.