ImageGear .NET - Updated
CreateThumbnail Method
Example 




ImageGear24.Core Assembly > ImageGear.Processing Namespace > ImGearProcessing Class : CreateThumbnail Method
Source image from which the thumbnail is created.
Width of the thumbnail.
Height of the thumbnail.
Interpolation options.
Creates a thumbnail image according to the specified dimensions.
Syntax
'Declaration
 
Public Shared Function CreateThumbnail( _
   ByVal page As ImGearPage, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal options As ImGearInterpolationOptions _
) As ImGearPage
'Usage
 
Dim page As ImGearPage
Dim width As Integer
Dim height As Integer
Dim options As ImGearInterpolationOptions
Dim value As ImGearPage
 
value = ImGearProcessing.CreateThumbnail(page, width, height, options)
public static ImGearPage CreateThumbnail( 
   ImGearPage page,
   int width,
   int height,
   ImGearInterpolationOptions options
)
public: static ImGearPage* CreateThumbnail( 
   ImGearPage* page,
   int width,
   int height,
   ImGearInterpolationOptions* options
) 
public:
static ImGearPage^ CreateThumbnail( 
   ImGearPage^ page,
   int width,
   int height,
   ImGearInterpolationOptions^ options
) 

Parameters

page
Source image from which the thumbnail is created.
width
Width of the thumbnail.
height
Height of the thumbnail.
options
Interpolation options.

Return Value

New thumbnail image.
Remarks
This method processes all channels of the image.

Interpolation options depend on the color space and bit depth of the image. Grayscale, PreserveBlack and PreserveWhite interpolations are applicable only to 1 bit images.

Average and Bilinear interpolations are not applicable to 1 bit images nor to images having a non-gray palette. Also, Bilinear interpolation cannot be applied to the images if one of the dimensions is decreased.

Use ImGearProcessingVerifier.CanApplyCreateThumbnail method to check whether the operation can be performed.

Example
// Creates a thumbnail 100 pixels wide maintaining aspect ratio.

// Determine appropriate height.
int newHeight = 100 * igPage.DIB.Height / igPage.DIB.Width;

// Set default interpolation to none.
ImGearInterpolations igInterpolations = ImGearInterpolations.NONE;

// If the image is 1-bit and larger than 100x100, use grayscale interpolation.
if (igPage is ImGearRasterPage &&
    1 == igPage.DIB.BitDepth &&
    igPage.DIB.Width >= 100 &&
    igPage.DIB.Height >= 100)
{
    igInterpolations = ImGearInterpolations.GRAYSCALE;
}

// Create the thumbnail using the default options for the chosen interpolation.
ImGearPage igPageThumbnail = ImGearProcessing.CreateThumbnail(igPage, 100, newHeight,
    ImGearInterpolationOptions.GetDefault(igInterpolations));
' Creates a thumbnail 100 pixels wide maintaining aspect ratio.

' Determine appropriate height.
Dim newHeight As Integer = 100 * igPage.DIB.Height / igPage.DIB.Width

' Set default interpolation to none.
Dim igInterpolations As ImGearInterpolations = ImGearInterpolations.NONE

' If the image is 1-bit and larger than 100x100, use grayscale interpolation.
If TypeOf igPage Is ImGearRasterPage AndAlso 1 = igPage.DIB.BitDepth AndAlso _
 igPage.DIB.Width >= 100 AndAlso igPage.DIB.Height >= 100 Then
    igInterpolations = ImGearInterpolations.GRAYSCALE
End If

' Create the thumbnail using the default options for the chosen interpolation.
Dim igPageThumbnail As ImGearPage
igPageThumbnail = ImGearProcessing.CreateThumbnail(igPage, 100, newHeight, _
 ImGearInterpolationOptions.GetDefault(igInterpolations))
See Also

Reference

ImGearProcessing Class
ImGearProcessing Members
ImGearRasterPage Class
ImGearInterpolationOptions Class
CanApplyCreateThumbnail Method
ImGearPage Class