ShellBrowser Delphi Edition Documentation
ContentsIndexHome
PreviousUpNext
TShellBrowser.GetThumbnailBitmap Method

Use GetThumbnailBitmap to get a TBitmap Thumbnail of the current file

Syntax
Pascal
function GetThumbnailBitmap(pWidth: Integer; pHeight: Integer; pIconInstead: Boolean = False): TBitmap;

GetThumbNailBitmap generates a thumbnail of the current file and assigns it to he Bitmap that was passed as argument. The size of the generated Thumbnail may be adjusted using the Width and Height property of the Bitmap. The function returns true if the thumbnail was generated successfully and false otherwise. The function works similar to GetThumbNailImage. If you call this function for a thread, COM must be initialized using CoInitializeEx(). For informations about CoInitializeEx() see: http://msdn.microsoft.com/en-us/library/ms695279%28VS.85%29.aspx

This procedure for the VCL version creates a thumbnail image of a file and saves it to a JPEG-file. The path to the source file and the path of the resulting JPEG-file must be given when procedure is called. The height and width of the thumbnail image are optional parameters that have a default value of 100. Borland's jpeg unit must be included in the uses clause.

uses jpeg, shellbrowser, graphics; procedure GetThumbnail(aSourceFilename, aThumbnailFilename: String; ThumbnailWidth: integer = 100; ThumbnailHeight: integer = 100); var jpegimage : TJpegImage; fshellbrowser : ShellBrowser; bitmap : TBitmap; begin jpegimage := Tjpegimage.Create; try fshellbrowser := ShellBrowser.Create(nil); try bitmap := TBitmap.Create; try fshellbrowser.ObjectName := aSourceFilename; bitmap.Handle := fshellbrowser.GetThumbnailBitmap(ThumbnailWidth,ThumbnailHeight); jpegimage.Assign(bitmap); jpegimage.CompressionQuality := 85; jpegimage.compress; jpegimage.savetofile(aThumbnailFilename); finally bitmap.Free; end;//try..finally bitmap finally fshellbrowser.Free; end;//try..finally fshellbrowser finally jpegimage.Free; end;//try..finally jpegimage end;
Copyright (c) 2011. All rights reserved.