Board index » delphi » DBImage and proportional stretch
Friedhelm Drecktrah
![]() Delphi Developer |
Friedhelm Drecktrah
![]() Delphi Developer |
DBImage and proportional stretch2005-09-13 09:36:41 PM delphi83 Hi, does anybody know how I can stretch DBImage proportional like Image? Thanks Friedhelm Drecktrah, Germany |
Erick Hartanto
![]() Delphi Developer |
2005-09-13 10:23:39 PM
Re:DBImage and proportional stretch
didn't it have Stretch property ?
Best Regards Erick |
Geoff Marshall
![]() Delphi Developer |
2005-09-14 11:03:43 PM
Re:DBImage and proportional stretch
Friedhelm Drecktrah writes:
QuoteHi, To fill a panel with borders change if ratioh < ratiow then ratio := ratiow else ratio := ratioh; to if ratioh>ratiow then ratio := ratiow else ratio := ratioh; Procedure Tf_Main.ScaleImage(Image: TImage); var ratio, ratiow, ratioh: real; panel: TPanel; OrgHeight, OrgWidth : integer; //Org == Original begin if Image <>nil then begin Image.stretch := false;//these 2 lines allow image to return to its Image.AutoSize := true; // ...original size prior to re-sizing OrgHeight := image.height; OrgWidth := image.width; if (image.width>0 ) and (image.height>0) then begin Image.autosize := false; Image.stretch := true; ratiow := Panel.width / image.width; ratioh := Panel.height / image.height; if ratioh < ratiow then ratio := ratiow else ratio := ratioh; //scale up to fit image.width := trunc(OrgWidth * ratio); image.height := trunc(OrgHeight * ratio); image.left := trunc((panel.width - image.width)/2); image.top := trunc((panel.height - image.height)/2); //these 2 lines center the image in the panel end end; end; |