Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ReadThumbnail Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : ReadThumbnail Method



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.
Creates a thumbnail from the specified image file.

Syntax

Visual Basic (Declaration) 
Public Function ReadThumbnail( _
   ByVal fileName As String, _
   ByVal options As CodecsThumbnailOptions, _
   ByVal pageNumber As Integer _
) As RasterImage
Visual Basic (Usage)Copy Code
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)
C# 
public RasterImage ReadThumbnail( 
   string fileName,
   CodecsThumbnailOptions options,
   int pageNumber
)
C++/CLI 
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.

Example

This example will read a thumbnail from a CMP file

Visual BasicCopy Code
Public Sub ReadThumbnailExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()

   Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "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.FromGdiPlusColor(Color.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()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void ReadThumbnailExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "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.FromGdiPlusColor(Color.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(); 
   RasterCodecs.Shutdown(); 
}

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.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also