resizing Pictures

I have n-pictures and i need to resizing de pictures and save with this scale, example:

If  i have a BMP of 800x600 pixels i need to save at 600x400 without lose definition in the Picture
garizpeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edeyCommented:
well, less pixels means less data, period.  There are two basic approaches:

1)Firstly, try canvas.stretchdraw.  This is but a wrapper for the stretchBLT api & generally works o.k.

2)Rewrite stretchBlt to do the kind of dithering you want.

You could also convert te bmp to a jpeg & use the TJpegImage to resize & control quality.

GL
Mike
0
williams2Commented:
Hi Garizpe,

I know exactly what you mean, because the tretchdraw won't do you no good, because the stadard image resizing, you have allready tried, is done by the StretchBlt API method, which will not try to calculate an alternative bitmap.

So, what you really need is a method to stretch your bitmap applying all the range of colors to it without having those "bumby" lines, and I think I know where you should look to get this done:

A very good site known to me is:
www.melander.dk

The author Anders Melander has done quite a job showing how to resize a picture loosing as little as possible doing it (I have used it - even rescaling from 400x650 to 20x25 - and I could still see the picture clearly even if it is small)

...the link to the "thing" you need is found below:
http://www.melander.dk/delphi/resampler/index.html

The nice guy, who put this together, has included a sample, where he demonstrates many different methods of using his algorithm.

if you got any questions, feel free to ask.

Regards,
Williams
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
men xinCEOCommented:
garizpe:

For your 20 points,it is so easy!

var a:Tbitmap;
begin
  a:=TBitmap.Create;
  a.LoadFromFile('c:\a.bmp');  //load a Source bitmap 800x600
  with TBitmap.Create do begin      //Create a new one
    ...  //set other b's property ,for example :pixformat....
    Width:=640;
    Height:=480; //reset the width and height
    Canvas.StretchDraw(b.Canvas.ClipRect,a); //Draw!!
    SaveToFile('c:\b.bmp');  //Save the result.
    free;
  end;
  a.free;
end;
0
men xinCEOCommented:
garizpe:

For your 20 points,it is so easy!

var a:Tbitmap;
begin
  a:=TBitmap.Create;
  a.LoadFromFile('c:\a.bmp');  //load a Source bitmap 800x600
  with TBitmap.Create do begin      //Create a new one
    ...  //set other b's property ,for example :pixformat....
    Width:=640;
    Height:=480; //reset the width and height
    Canvas.StretchDraw(b.Canvas.ClipRect,a); //Draw!!
    SaveToFile('c:\b.bmp');  //Save the result.
    free;
  end;
  a.free;
end;

menxin
0
williams2Commented:
Hmmmm....

Menxin, don't underestimate a question as the user asked this to be done without loosing definitions in the picture.
The stretchdraw method does not interpolate the image, why the image will sometimes look very weird.

Regards,
Williams
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.