public void FromByte(
byte[] value
)
- (void)fromByte:(unsigned char *)buffer itemCount:(NSUInteger)count
public void fromByte(
byte[] byte[Value
);
public:
void FromByte(
array<byte>^ value
)
def FromByte(self,value):
value
The data to set.
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:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.IOException;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
public void RasterCommentMetadataExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
RasterCodecs codecs = new RasterCodecs();
codecs.setThrowExceptionsOnInvalidImages(true);
String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1.cmp");
String destFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1_comments.tif");
ILeadStream destFileStream = LeadStreamFactory.create(destFileName);
// 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.setType(RasterCommentMetadataType.ARTIST);
String artistNameWrite = "Artist name";
comment.fromAscii(artistNameWrite);
System.out.println("Writing Artist");
codecs.writeComment(destFileStream, 1, comment);
comment.setType(RasterCommentMetadataType.GPS_LATITUDE);
RasterMetadataRational[] rationalsWrite = new RasterMetadataRational[3];
for (int i = 0; i < rationalsWrite.length; i++)
rationalsWrite[i] = new RasterMetadataRational(i + 3, i + 2);
comment.fromRational(rationalsWrite);
System.out.println("Writing GpsLatitude");
codecs.writeComment(destFileStream, 1, comment);
// Now read the comments from the tif file
// read ASCII
comment = codecs.readComment(destFileName, 1, RasterCommentMetadataType.ARTIST);
String artistNameRead = comment.toAscii();
System.out.printf("Artist Read: %s\n", artistNameRead);
System.out.printf("Artist Written: %s\n", artistNameWrite);
assertTrue(artistNameRead.equals(artistNameWrite));
// read rationals
comment = codecs.readComment(destFileName, 1, RasterCommentMetadataType.GPS_LATITUDE);
RasterMetadataRational[] rationalsRead = comment.toRational();
int size = rationalsRead.length;
System.out.printf("GpsLatitude: size = %d \n", size);
for (int i = 0; i < size; i++)
System.out.printf("%d/%d\n", rationalsRead[i].getNumerator(), rationalsRead[i].getDenominator());
assertTrue(rationalsRead.length == rationalsWrite.length);
for (int i = 0; i < rationalsRead.length; i++) {
assertTrue(rationalsRead[i].getNumerator() == rationalsWrite[i].getNumerator());
assertTrue(rationalsRead[i].getDenominator() == rationalsWrite[i].getDenominator());
}
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document