Solved

How create thumbnails?

Posted on 1998-04-26
6
192 Views
Last Modified: 2010-04-06
HI!

I have a bunch of scanned photographs, about 600 x 430 pixels in size. In my application I want to create thumbnails for all these pictures and save them to disk in BMP format. How do I transfer/resize the big pictures into thumbnails? I tried using CopyRect from the big image to a small one, but the colors were all mixed up and looked really weird in the small picture, almost like graffiti.
NOTE: I want this done in the background, so reading the form's canvas or anything like that is no good.

Anybody?

//Daniel, Sweden
0
Comment
Question by:Dippen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1337126
For fancy zoom out you should do averaging. i.e. you should produce the thumb nail by hand. Let the following be the 2x2 picture
1 2
3 4   -- is transformed to  a single pixel by  (1+2+3+4) / 4
The resulting image is better than just picking one pixel from that 4 pixels. So after deciding the zoom ration you take the average of some pixel for thumb nail
Regards,
Igor
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1337127
Hello Dippen and Inter,

Yep Igor is right (like always), but there are lots of other ways getting such thumbnails. A few months ago I found a really good looking site. It 's the site of Anders Melander. He has some great components and some great links to graphical stuff (Algorithemes etc.). And one of his freeware components is a bitmap resampler (lots of algorithemes included). So I think this is the easiest way of implementing your thumbnails....

(Igor : It's really worth looking at it!)

http://www.melander.dk/delphi/resampler/index.html

Regards, ZiF.
0
 

Author Comment

by:Dippen
ID: 1337128
Thanks for your answer, Zif! I've looked at Anders Melanders components, but it seems as if they're a little to much for my needs right now, if you know what I mean. Delphi obviously has some sort of routine for rescaling pictures, since Delphi produces a high-quality thumbnail if I set the Stretch property of an TImage to True and then make the TImage component smaller. Can't I use that capability in some easy way?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:inter
ID: 1337129
Actually, delphi does nothing special this is the Paint Routine for TImage:

procedure TImage.Paint;
var
  Dest: TRect;
begin
  if Stretch then
    Dest := ClientRect
  else if Center then
    Dest := Bounds((Width - Picture.Width) div 2, (Height - Picture.Height) div 2,
      Picture.Width, Picture.Height)
  else
    Dest := Rect(0, 0, Picture.Width, Picture.Height);
  with inherited Canvas do
    StretchDraw(Dest, Picture.Graphic);
end;

Regards, (so they just use StretchDraw)
Igor
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337130
Correct, You could save the dest canvas to a file...
0
 

Author Comment

by:Dippen
ID: 1337131
Whoomp, there it is!

Thx, guys, I love you both! I feel just a little tiny bit stupid since there was such an easy solution to the problem, but what the h... Cya!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 359
Downloading email attachments 2 85
How to build JSON File in Delphi 6 3 71
Installshield for Embarcadero EX 10.1 Berlin 4 74
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question