←Select platform

SetData Method

Summary
Sets the data (an array of bytes) for this comment.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public void SetData( 
   byte[] value 
) 
@property (nonatomic, strong) NSData *data 
public void setData(byte[] value) 
public: 
void SetData(  
   array<byte>^ value 
)  
def SetData(self,value): 

Parameters

value
The data for this comment, stored as an array of bytes.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void RasterCommentMetadataExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
	codecs.ThrowExceptionsOnInvalidImages = true; 
 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
	string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_comments.tif"); 
 
	// Load the image 
	RasterImage image = codecs.Load(srcFileName); 
	codecs.Save(image, destFileName, RasterImageFormat.Tif, 24); 
 
	image.Dispose(); 
 
	// Write some comments to the existing tif file 
	RasterCommentMetadata comment = new RasterCommentMetadata(); 
	comment.Type = RasterCommentMetadataType.Artist; 
	string artistNameWrite = "Artist name"; 
	comment.FromAscii(artistNameWrite); 
	Console.WriteLine("Writing Artist"); 
	codecs.WriteComment(destFileName, 1, comment); 
 
	comment.Type = RasterCommentMetadataType.GpsLatitude; 
	RasterMetadataRational[] rationalsWrite = new RasterMetadataRational[3]; 
	for (int i = 0; i < rationalsWrite.Length; i++) 
		rationalsWrite[i] = new RasterMetadataRational(i + 3, i + 2); 
 
	comment.FromRational(rationalsWrite); 
	Console.WriteLine("Writing GpsLatitude"); 
	codecs.WriteComment(destFileName, 1, comment); 
 
	// Now read the comments from the tif file 
 
	// read ASCII 
	comment = codecs.ReadComment(destFileName, 1, RasterCommentMetadataType.Artist); 
	string artistNameRead = comment.ToAscii(); 
	Console.WriteLine("Artist: {0}", artistNameRead); 
	Assert.IsTrue(artistNameRead == artistNameWrite); 
 
	// read rationals 
	comment = codecs.ReadComment(destFileName, 1, RasterCommentMetadataType.GpsLatitude); 
	RasterMetadataRational[] rationalsRead = comment.ToRational(); 
 
	int size = rationalsRead.Length; 
	Console.WriteLine("GpsLatitude: size = {0} ", size); 
	for (int i = 0; i < size; i++) 
		Console.WriteLine("{0}/{1}", rationalsRead[i].Numerator, rationalsRead[i].Denominator); 
 
	Assert.IsTrue(rationalsRead.Length == rationalsWrite.Length); 
	for (int i = 0; i < rationalsRead.Length; i++) 
	{ 
		Assert.IsTrue(rationalsRead[i].Numerator == rationalsWrite[i].Numerator); 
		Assert.IsTrue(rationalsRead[i].Denominator == rationalsWrite[i].Denominator); 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.