[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 123456[7]8910 ]

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 10:46:01 10/31/01 Wed
Author: Tim Griffin
Subject: Re: How to create an application to have thumbnails?
In reply to: ANDREW DIABO 's message, "How to create an application to have thumbnails?" on 16:23:21 10/25/01 Thu

Here's a Delphi 5 procedure that makes thumbnails.
I'm also looking forward to seeing Michel's example.

This procedure even expands pictures with Michel's interpolation routines if the requested 'thumbnail' is larger than the original picture (cool Michel, thanks for the functionality!).

The first 2 parameters provide the input filename and the output filename of a JPG image.

The last 4 parameters specify the size of the 'thumbnail'.
- Use MaxH and MaxW to specify the max. number of pixels per side (I use these to resize pictures to fit them on a PC screen). Example: 768,1024,0,0 -or- 600,800,0,0.
- or Use MinH and MinW to specify the min. number of pixels per side (I use these for my 'real' thumbnails). Example: 0,0,150,150.

The only other thing that's needed on a Delphi form to make this work is a TImageScrollBox (ImageScrollBox1) which can be invisible.

Procedure CreateThumbnail2(InFileName, OutFileName: string;
maxh, maxw, minh, minw:longint);
Transform : TResizeTransform;
ratio : real;
h,w : longint;
JPGGraphic : TJpegGraphic;

if (not fileexists(outfilename)) or (filesiz(outfilename) < 1) or
(fileage(outfilename) <= fileage(infilename))
then begin
with form1 do begin
JPGGraphic := TJpegGraphic.Create;
Transform := TResizeTransform.Create;


TJpegGraphic(JPGGraphic).SaveQuality := thumbs2jpgquality;

h := ImageScrollBox1.Graphic.Height;
w := ImageScrollBox1.Graphic.Width;

ratio := 0;
if maxh > 0 then begin
if (maxh / h) < (maxw / w) then
ratio := maxh / h
ratio := maxw / w;

if minh > 0 then begin
if (minh / h) > (minw / w) then
ratio := minh / h
ratio := minw / w;

if ratio > 1 then begin
Transform.Interpolated := true;
Transform.Filter := TInterpolationFilter(0); // Triangle

Transform.Width := round(w * ratio);
Transform.Height := round(h * ratio);
Transform.ApplyOnDest(JPGGraphic, ImageScrollBox1.Graphic);


[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]

Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.