Leadtools.Codecs Namespace > RasterCodecs Class > ReadThumbnail Method : ReadThumbnail(String,CodecsThumbnailOptions,Int32) Method |
public RasterImage ReadThumbnail( string fileName, CodecsThumbnailOptions options, int pageNumber )
'Declaration Public Overloads Function ReadThumbnail( _ ByVal fileName As String, _ ByVal options As CodecsThumbnailOptions, _ ByVal pageNumber As Integer _ ) As RasterImage
'Usage Dim instance As RasterCodecs Dim fileName As String Dim options As CodecsThumbnailOptions Dim pageNumber As Integer Dim value As RasterImage value = instance.ReadThumbnail(fileName, options, pageNumber)
public RasterImage ReadThumbnail( string fileName, CodecsThumbnailOptions options, int pageNumber )
function Leadtools.Codecs.RasterCodecs.ReadThumbnail(String,CodecsThumbnailOptions,Int32)( fileName , options , pageNumber )
public: RasterImage^ ReadThumbnail( String^ fileName, CodecsThumbnailOptions options, int pageNumber )
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
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(); }); } } }
[TestMethod] 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(); }
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(); }
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
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2