Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg
Private Sub DisplayComment(ByVal comment As RasterCommentMetadata)
Select Case comment.DataType
Case RasterCommentMetadataDataType.Ascii
MessageBox.Show("Comment of type " & comment.Type.ToString() & " = " & comment.ToAscii())
End Select
End Sub
Public Sub CommentsExample()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))
'Ascii
Dim commentDataAscii As RasterCommentMetadata = New RasterCommentMetadata()
' set the artist comment
commentDataAscii.Type = RasterCommentMetadataType.Artist
commentDataAscii.FromAscii("Test String")
image.Comments.Add(commentDataAscii)
codecs.Options.Save.Comments = True
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_COMMENTS.TIF"), RasterImageFormat.Tif, 0)
' load the comment together with the image
Dim comment As RasterCommentMetadata = codecs.ReadComment(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_COMMENTS.TIF"), 1, _
RasterCommentMetadataType.Artist)
DisplayComment(comment)
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;
private void DisplayComment(RasterCommentMetadata comment)
{
switch(comment.DataType)
{
case RasterCommentMetadataDataType.Ascii:
MessageBox.Show("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii());
break;
}
}
public void CommentsExample()
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP"));
//Ascii
RasterCommentMetadata commentDataAscii = new RasterCommentMetadata();
// set the artist comment
commentDataAscii.Type = RasterCommentMetadataType.Artist;
commentDataAscii.FromAscii("Test String");
image.Comments.Add(commentDataAscii);
codecs.Options.Save.Comments = true;
codecs.Save(image,Path.Combine(ImagesPath.Path, "IMAGE1_COMMENTS.TIF"), RasterImageFormat.Tif, 0);
// load the comment together with the image
RasterCommentMetadata comment = codecs.ReadComment(Path.Combine(ImagesPath.Path, "IMAGE1_COMMENTS.TIF"), 1, RasterCommentMetadataType.Artist);
DisplayComment(comment);
codecs.Dispose();
}
function DisplayComment(comment)
{
switch (comment.dataType)
{
case Leadtools.RasterCommentMetadataDataType.ascii:
console.info("Comment of type " + comment.type.toString() + " = " + comment.toAscii());
break;
}
}
RasterImageExamples.prototype.CommentsExample = function () {
Tools.SetLicense();
with (Leadtools) {
with (Leadtools.Codecs) {
var codecs = new RasterCodecs();
var srcFileName = "Assets\\Image1.cmp";
var image;
return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
return codecs.loadAsync(LeadStreamFactory.create(loadFile))
})
.then(function (img) {
image = img;
//Ascii
var commentDataAscii = new RasterCommentMetadata();
// set the artist comment
commentDataAscii.type = RasterCommentMetadataType.artist;
commentDataAscii.fromAscii("Test String");
image.comments.append(commentDataAscii);
codecs.options.save.comments = true;
return Tools.AppLocalFolder().createFileAsync("IMAGE1_COMMENTS.TIF")
})
.then(function (saveFile) {
var saveStream = LeadStreamFactory.create(saveFile);
return codecs.saveAsync(image, saveStream, RasterImageFormat.tif, 0)
})
.then(function () {
// load the comment together with the image
return Tools.AppLocalFolder().getFileAsync("IMAGE1_COMMENTS.TIF")
})
.then(function (loadFile) {
return codecs.readCommentAsync(LeadStreamFactory.create(loadFile), 1, RasterCommentMetadataType.artist)
})
.then(function (comment) {
DisplayComment(comment);
image.close();
codecs.close();
});
}
}
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
private void DisplayComment(RasterCommentMetadata comment)
{
switch (comment.DataType)
{
case RasterCommentMetadataDataType.Ascii:
Debug.WriteLine("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii());
break;
}
}
public async Task CommentsExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = @"Assets\Image1.cmp";
StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
//Ascii
RasterCommentMetadata commentDataAscii = new RasterCommentMetadata();
// set the artist comment
commentDataAscii.Type = RasterCommentMetadataType.Artist;
commentDataAscii.FromAscii("Test String");
image.Comments.Add(commentDataAscii);
codecs.Options.Save.Comments = true;
StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("IMAGE1_COMMENTS.TIF");
ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
await codecs.SaveAsync(image, saveStream, RasterImageFormat.Tif, 0);
// load the comment together with the image
loadFile = await Tools.AppLocalFolder.GetFileAsync("IMAGE1_COMMENTS.TIF");
RasterCommentMetadata comment = await codecs.ReadCommentAsync(LeadStreamFactory.Create(loadFile), 1, RasterCommentMetadataType.Artist);
DisplayComment(comment);
codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;
private void DisplayComment(RasterCommentMetadata comment)
{
switch (comment.DataType)
{
case RasterCommentMetadataDataType.Ascii:
Debug.WriteLine("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii());
break;
}
}
public void CommentsExample(RasterImage image, Stream destStream)
{
//Ascii
RasterCommentMetadata commentDataAscii = new RasterCommentMetadata();
// set the artist comment
commentDataAscii.Type = RasterCommentMetadataType.Artist;
commentDataAscii.FromAscii("Test String");
image.Comments.Add(commentDataAscii);
RasterCodecs codecs = new RasterCodecs();
codecs.Options.Save.Comments = true;
codecs.Save(image, destStream, RasterImageFormat.Tif, 0);
// load the comment together with the image
RasterCommentMetadata comment = codecs.ReadComment(destStream, 1, RasterCommentMetadataType.Artist);
DisplayComment(comment);
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media
Private Sub DisplayComment(ByVal comment As RasterCommentMetadata)
Select Case comment.DataType
Case RasterCommentMetadataDataType.Ascii
Debug.WriteLine("Comment of type " & comment.Type.ToString() & " = " & comment.ToAscii())
End Select
End Sub
Public Sub CommentsExample(ByVal image As RasterImage, ByVal destStream As Stream)
'Ascii
Dim commentDataAscii As RasterCommentMetadata = New RasterCommentMetadata()
' set the artist comment
commentDataAscii.Type = RasterCommentMetadataType.Artist
commentDataAscii.FromAscii("Test String")
image.Comments.Add(commentDataAscii)
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.Options.Save.Comments = True
codecs.Save(image, destStream, RasterImageFormat.Tif, 0)
' load the comment together with the image
Dim comment As RasterCommentMetadata = codecs.ReadComment(destStream, 1, RasterCommentMetadataType.Artist)
DisplayComment(comment)
End Sub