Solved

How create thumbnails?

Posted on 1998-04-26
6
186 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
  • 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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