ShellBrowser Delphi Components Documentation
|
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, jamtemidlist, graphics, jam.shell.thumbnail; procedure GetThumbnail(aSourceFilePath, aThumbnailFilename: String; ThumbnailWidth: integer = 100; ThumbnailHeight: integer = 100); var jpegImage : TJPEGImage; bitmap : TBitmap; itemIdList: IItemIdList; begin itemIdList := TJamItemIdList.Create(aSourceFilePath); jpegImage := TJPEGImage.Create; try bitmap := TJamThumbnailExtractor.GetThumbnailBitmap(itemIdList, ThumbnailWidth, ThumbnailHeight); if assigned(bitmap) then begin //if the file doesn't have a thumbnail, the bitmap will not be assigned. try jpegImage.Assign(bitmap); jpegImage.CompressionQuality := 85; jpegImage.Compress; jpegImage.Savetofile(aThumbnailFilename); finally bitmap.Free; end;//try..finally bitmap end; finally jpegimage.Free; end;//try..finally jpegimage end;