←Select platform

ReadThumbnail(string,CodecsThumbnailOptions,int) Method

Summary
Creates a thumbnail from the specified image file.
Syntax
C#
VB
Objective-C
C++
public RasterImage ReadThumbnail( 
   string fileName, 
   CodecsThumbnailOptions options, 
   int pageNumber 
) 
Public Overloads Function ReadThumbnail( _ 
   ByVal fileName As String, _ 
   ByVal options As CodecsThumbnailOptions, _ 
   ByVal pageNumber As Integer _ 
) As RasterImage 
- (nullable LTRasterImage *)readThumbnailFromFile:(NSString *)file  
                                          options:(LTCodecsThumbnailOptions *)thumbnailOptions  
                                       pageNumber:(NSInteger)pageNumber  
                                            error:(NSError **)error 
public: 
RasterImage^ ReadThumbnail(  
   String^ fileName, 
   CodecsThumbnailOptions options, 
   int pageNumber 
)  

Parameters

fileName
A String containing the name of the file from which the thumbnail image will be created.

options
Options for creating the thumbnail image.

pageNumber
1-based index of the page from which the thumbnail image should be created.

Return Value

The RasterImage object that this method creates.

Remarks

This method will always return a thumbnail image. Depending on the options passed, this method might read the stamp stored inside EXIF, CMP, JFIF and FlashPix files and return that. To read the file stamp only, use ReadStamp.

Example

This example will read a thumbnail from a CMP file

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
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:\LEADTOOLS21\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Codecs Assembly

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