Open the FolderMView demo in the ..\Multi\FolderMView samples folder.
Add a TCheckBox next to the show preview checkbox at the bottom of the form adjacent to the ShowPreview checkbox. Give the checkbox a name of Thumbnail1. Add hyieutils, iexHelperFunctions to implementation uses.
Then replace the code in the tmrUpdatePreviewTimer event with:
procedure TForm1.tmrUpdatePreviewTimer(Sender: TObject);
var
iMaxX: Integer;
iMaxY: Integer;
iCanStretch: Boolean;
iQualityFilter: TResampleFilter;
iAddBorder: Boolean;
iBorderColor: TColor;
iAddShadow: Boolean;
iBlurRadius: Integer;
iShadowOffset: Integer;
iShadowColor: TColor;
iBackgroundColor: TColor;
iIEBitmap: TIEBitmap;
begin
tmrUpdatePreview.Enabled := False;
if chkPreview.checked = False then
ImageEnView1.Blank
else if ImageEnView1.IO.Params.Filename <> IEFolderMView.SelectedFilename then
begin
if IEFolderMView.SelectedFilename = '' then
ImageEnView1.Blank
else
begin
{ Set the thumbnail parameters }
iMaxX := ImageEnView1.ClientWidth;
iMaxY := ImageEnView1.ClientHeight;
iCanStretch := False;
iQualityFilter := rfLanczos3;
iAddBorder := True;
iBorderColor := clWhite;
iAddShadow := True;
iBlurRadius := 4;
iShadowOffset := 4;
iShadowColor := clBlack;
iBackgroundColor := clWhite;
{ If thumbnail is checked then get the image from IEFolderMView and
convert it to a thumbnail. Assign the thumbnail to ImageEnView1 and
update ImageEnView1. Then release the bitmap to prevent memory leak! }
if Thumbnail1.Checked then
begin
iIEBitmap := IEFolderMView.GetTIEBitmap(IEFolderMView.SelectedImage);
iIEBitmap.IEConvertToThumbnail(iMaxX, iMaxY, iCanStretch,
iQualityFilter, iAddBorder, iBorderColor, iAddShadow, iBlurRadius,
iShadowOffset, iShadowColor, iBackgroundColor);
ImageEnView1.IEBitmap.Assign(iIEBitmap);
ImageEnView1.Update;
IEFolderMView.ReleaseBitmap(IEFolderMView.SelectedImage);
end
else
{ Load the image from a file }
begin
ImageEnView1.IO.LoadFromFile(IEFolderMView.SelectedFilename);
end;
end;
end;
end;
If the show preview checkbox is checked and the thumbnail checkbox is checked, a thumbnail of the selected image will be created and displayed. A thumbnail of System images as well as supported file types will be created. If the thumbnail checkbox is not checked, then the full image will be loaded from disk if the selected image is a supported file type and is not a system image.
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html