GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / GetPageThumbnailAsBitmap Method
The required width of the newly created thumbnail image, in pixels.
The required height of the newly created thumbnail image, in pixels.
The required page of the displayed document for creating the thumbnail.
A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides painted with the specified color.
Example





In This Topic
GetPageThumbnailAsBitmap Method
In This Topic
Creates a custom sized high quality (HQ) thumbnail of the specified page of the document displayed in the GdViewer control as a bitmap. The required page is converted to an image thumbnail that fits within a rectangle of the size and the background color you have specified.
Syntax
'Declaration
 
Public Function GetPageThumbnailAsBitmap( _
   ByVal Width As Integer, _
   ByVal Height As Integer, _
   ByVal Page As Integer, _
   ByVal BackColor As Color _
) As Bitmap
public Bitmap GetPageThumbnailAsBitmap( 
   int Width,
   int Height,
   int Page,
   Color BackColor
)
public function GetPageThumbnailAsBitmap( 
    Width: Integer;
    Height: Integer;
    Page: Integer;
    BackColor: Color
): Bitmap; 
public function GetPageThumbnailAsBitmap( 
   Width : int,
   Height : int,
   Page : int,
   BackColor : Color
) : Bitmap;
public: Bitmap* GetPageThumbnailAsBitmap( 
   int Width,
   int Height,
   int Page,
   Color BackColor
) 
public:
Bitmap^ GetPageThumbnailAsBitmap( 
   int Width,
   int Height,
   int Page,
   Color BackColor
) 

Parameters

Width
The required width of the newly created thumbnail image, in pixels.
Height
The required height of the newly created thumbnail image, in pixels.
Page
The required page of the displayed document for creating the thumbnail.
BackColor
A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides painted with the specified color.

Return Value

The newly created thumbnail's image as a bitmap. Please first of all use the GetStat method to determine if this method has been successful.
Remarks
It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Example
How to save the current page of the displayed document as a thumbnail in the PNG format using a bitmap.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim thumbnail As Bitmap = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180))
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        thumbnail.Save("thumbnail.png")
        MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail")
    Else
        MessageBox.Show("The thumbnail can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail")
    End If
Else
    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    Bitmap thumbnail = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180));
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        thumbnail.Save("thumbnail.png");
        MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail");
    }
    else
        MessageBox.Show("The thumbnail can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail");
}
else
    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail");
See Also