Thumbnail Graphics,In snap shots “programming” a thumbnail is a reduced-length model of a photograph.
Here’s an concept for your subsequent application: create a “shape picker” to let users easily pick out and navigate through open paperwork by using displaying thumbnails of them all in a dialog window.
Interesting concept? Sounds just like the “Quick Tabs” feature of the IE 7 browser 🙂
Before absolutely developing this kind of neat function for your next Delphi utility,
you want to realize the way to snatch the picture of the shape (“shape-display screen shot”) and how to proportionally resize it to the preferred thumbnail photo.
Proportional Picture Resizing: Creating Thumbnail Graphics
Thumbnail Graphics,Below you may discover a block of code to take the photograph of a form (Form1) with the aid of using the GetFormImage technique.
The ensuing TBitmap is then resized to fit the maximum thumbnail width (200 pixels) and/or height (150 pixels). Resizing keeps the element ratio of the image.
The ensuing photo is then displayed in a TImage manipulate, named “Image1”.
rtional Picture Resizing: Creating Thumbnail Graphics
const
maxWidth = 200;
maxHeight = 150;
var
thumbnail : TBitmap;
thumbRect : TRect;
begin
thumbnail := Form1.GetFormImage;
try
thumbRect.Left := 0;
thumbRect.Top := 0;
//proportional resize
if thumbnail.Width > thumbnail.Height then
begin
thumbRect.Right := maxWidth;
thumbRect.Bottom := (maxWidth * thumbnail.Height) div thumbnail.Width;
end
else
begin
thumbRect.Bottom := maxHeight;
thumbRect.Right := (maxHeight * thumbnail.Width) div thumbnail.Height;
end;
thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;
//resize image
thumbnail.Width := thumbRect.Right;
thumbnail.Height := thumbRect.Bottom;
//display in a TImage control
Image1.Picture.Assign(thumbnail) ;
finally
thumbnail.Free;
end;
end;
Note:The GetFormImage only copies the shape client place – if you need to take the whole “display screen shot” of a shape (which includes its border) you will want a special technique …Greater about it next time.