Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing
Public Sub ReadThumbnailExample()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
' Create a thumbnail with default options
Dim options As CodecsThumbnailOptions = CodecsThumbnailOptions.Default
options.LoadStamp = False
Dim thumbnail As RasterImage = codecs.ReadThumbnail(srcFileName, options, 1)
Console.WriteLine("Thumbnail with default option:")
Console.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
thumbnail.Dispose()
' Create a thumbnail with some options
options.LoadStamp = False
options.Width = 40
options.Height = 80
options.ForceSize = True
options.MaintainAspectRatio = False
options.BackColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue)
options.BitsPerPixel = 8
thumbnail = codecs.ReadThumbnail(srcFileName, options, 1)
Console.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}", options.Width, options.Height, options.BitsPerPixel, options.ForceSize)
Console.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
thumbnail.Dispose()
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.Color;
public void ReadThumbnailExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
// Create a thumbnail with default options
CodecsThumbnailOptions options = CodecsThumbnailOptions.Default;
options.LoadStamp = false;
RasterImage thumbnail = codecs.ReadThumbnail(srcFileName, options, 1);
Console.WriteLine("Thumbnail with default option:");
Console.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
// Create a thumbnail with some options
options.LoadStamp = false;
options.Width = 40;
options.Height = 80;
options.ForceSize = true;
options.MaintainAspectRatio = false;
options.BackColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue);
options.BitsPerPixel = 8;
thumbnail = codecs.ReadThumbnail(srcFileName, options, 1);
Console.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
Console.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
RasterCodecsExamples.prototype.ReadThumbnailExample = function () {
Tools.SetLicense();
with (Leadtools) {
with (Leadtools.Codecs) {
var codecs = new RasterCodecs();
var srcFileName = "Assets\\Image1.cmp";
var thumbnail;
var loadFile;
// Create a thumbnail with default options
var options = new CodecsThumbnailOptions();
options.loadStamp = false;
return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFileX) {
loadFile = loadFileX;
return codecs.readThumbnailAsync(LeadStreamFactory.create(loadFile), options, 1)
})
.then(function (thumb) {
thumbnail = thumb;
console.info("Thumbnail with default option:");
console.info(" Size: ", thumbnail.width, " by ", thumbnail.Height, "pixels. Bits/Pixel: ", thumbnail.bitsPerPixel);
thumbnail.close();
// Create a thumbnail with some options
options.loadStamp = false;
options.width = 40;
options.height = 80;
options.forceSize = true;
options.maintainAspectRatio = false;
options.backColor = RasterColorHelper.fromKnownColor(RasterKnownColor.lightBlue);
options.bitsPerPixel = 8;
return codecs.readThumbnailAsync(LeadStreamFactory.create(loadFile), options, 1)
})
.then(function (thumb2) {
thumbnail = thumb2;
console.info("Thumbnail with set option (size: ", options.width, " by ", options.height, ", Bits/Pixel: ", options.bitsPerPixel, ", ForeSize: ", options.forceSize);
console.info(" Size: ", thumbnail.width, " by ", thumbnail.height, " pixels. Bits/Pixel: ", thumbnail.bitsPerPixel);
thumbnail.close();
codecs.close();
});
}
}
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
public async Task ReadThumbnailExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = @"Assets\Image1.cmp";
// Create a thumbnail with default options
CodecsThumbnailOptions options = new CodecsThumbnailOptions();
options.LoadStamp = false;
StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
RasterImage thumbnail = await codecs.ReadThumbnailAsync(LeadStreamFactory.Create(loadFile), options, 1);
Debug.WriteLine("Thumbnail with default option:");
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
// Create a thumbnail with some options
options.LoadStamp = false;
options.Width = 40;
options.Height = 80;
options.ForceSize = true;
options.MaintainAspectRatio = false;
options.BackColor = RasterColorHelper.FromKnownColor(RasterKnownColor.LightBlue);
options.BitsPerPixel = 8;
thumbnail = await codecs.ReadThumbnailAsync(LeadStreamFactory.Create(loadFile), options, 1);
Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Windows.Media;
public void ReadThumbnailExample(Stream inStreamCmp)
{
RasterCodecs codecs = new RasterCodecs();
// Create a thumbnail with default options
CodecsThumbnailOptions options = CodecsThumbnailOptions.Default;
options.LoadStamp = false;
RasterImage thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1);
Debug.WriteLine("Thumbnail with default option:");
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
// Create a thumbnail with some options
options.LoadStamp = false;
options.Width = 40;
options.Height = 80;
options.ForceSize = true;
options.MaintainAspectRatio = false;
options.BackColor = new RasterColor(0x00, 0x00, 0x7F);
options.BitsPerPixel = 8;
thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1);
Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
thumbnail.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media
Public Sub ReadThumbnailExample(ByVal inStreamCmp As Stream)
Dim codecs As RasterCodecs = New RasterCodecs()
' Create a thumbnail with default options
Dim options As CodecsThumbnailOptions = CodecsThumbnailOptions.Default
options.LoadStamp = False
Dim thumbnail As RasterImage = codecs.ReadThumbnail(inStreamCmp, options, 1)
Debug.WriteLine("Thumbnail with default option:")
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
thumbnail.Dispose()
' Create a thumbnail with some options
options.LoadStamp = False
options.Width = 40
options.Height = 80
options.ForceSize = True
options.MaintainAspectRatio = False
options.BackColor = New RasterColor(&H00, &H00, &H7F)
options.BitsPerPixel = 8
thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1)
Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}", options.Width, options.Height, options.BitsPerPixel, options.ForceSize)
Debug.WriteLine(" Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
thumbnail.Dispose()
End Sub