?
Solved

How create thumbnails?

Posted on 1998-04-26
6
Medium Priority
?
211 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

741 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