Link to home
Start Free TrialLog in
Avatar of garizpe
garizpe

asked on

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
Avatar of edey
edey

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
ASKER CERTIFIED SOLUTION
Avatar of williams2
williams2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
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
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