?
Solved

How create thumbnails?

Posted on 1998-04-26
6
Medium Priority
?
224 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 200 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
Independent Software Vendors: 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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