Solved

How create thumbnails?

Posted on 1998-04-26
6
182 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:inter
Comment Utility
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
Comment Utility
Correct, You could save the dest canvas to a file...
0
 

Author Comment

by:Dippen
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now