Science, Tech, Math › Computer Science Proportionally Resize an Image: Creating Thumbnail Graphics Share Flipboard Email Print Geber86 / Getty Images Computer Science Delphi Programming Delphi Tutorials Database Applications Advanced PHP Programming Perl Python Java Programming Javascript Programming C & C++ Programming Ruby Programming Visual Basic View More By Zarko Gajic Computer Science Expert MSCS, Computer Science, University of Osijek Zarko Gajic is experienced in SQL and has working knowledge of DB systems such as MS SQL Server, Firebird, Interbase, and Oracle. He is also proficient in XML, DHTML, and JavaScript. our editorial process Twitter Twitter Zarko Gajic Updated June 05, 2017 In graphics "programming" a thumbnail is a reduced-size version of a picture. Here's an idea for your next application: create a "form picker" to let users easily select and navigate through open forms by displaying thumbnails of them all in a dialog window. Interesting idea? Sounds like the "Quick Tabs" feature of the IE 7 browser :) Before actually creating such a neat feature for your next Delphi application, you need to know how to grab the image of the form ("form-screen shot") and how to proportionally resize it to the desired thumbnail image. Proportional Picture Resizing: Creating Thumbnail Graphics Below you will find a block of code to take the image of a form (Form1) by using the GetFormImage method. The resulting TBitmap is then resized to fit the maximum thumbnail width (200 pixels) and/or height (150 pixels).Resizing maintains the aspect ratio of the image. The resulting image is then displayed in a TImage control, named "Image1". 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 form client area - if you need to take the entire "screen shot" of a form (including its border) you'll need a different approach ...more about it next time. Cite this Article Format mla apa chicago Your Citation Gajic, Zarko. "Proportionally Resize an Image: Creating Thumbnail Graphics." ThoughtCo, Aug. 27, 2020, thoughtco.com/resize-an-image-creating-thumbnail-graphics-1058071. Gajic, Zarko. (2020, August 27). Proportionally Resize an Image: Creating Thumbnail Graphics. Retrieved from https://www.thoughtco.com/resize-an-image-creating-thumbnail-graphics-1058071 Gajic, Zarko. "Proportionally Resize an Image: Creating Thumbnail Graphics." ThoughtCo. https://www.thoughtco.com/resize-an-image-creating-thumbnail-graphics-1058071 (accessed January 25, 2021). copy citation