unit ResizeImage; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TfrmResize = class(TForm) grpSize: TGroupBox; Button1: TButton; Button2: TButton; Label1: TLabel; Label2: TLabel; edtWidth: TEdit; edtHeight: TEdit; grpResampleOptions: TGroupBox; chkAspectRatio: TCheckBox; lblFilter: TLabel; cmbFilter: TComboBox; procedure FormActivate(Sender: TObject); procedure edtWidthChange(Sender: TObject); procedure edtHeightChange(Sender: TObject); private { Private declarations } fDontChange: boolean; function GetResampling: Boolean; procedure SetResampling(const Value: Boolean); public { Public declarations } OrgWidth, OrgHeight: integer; property Resampling : Boolean read GetResampling write SetResampling; end; implementation uses Main; {$R *.DFM} procedure TfrmResize.FormActivate(Sender: TObject); begin fDontChange := true; edtWidth.text := inttostr(OrgWidth); edtHeight.text := inttostr(OrgHeight); fDontChange := false; FillComboWithFilters( cmbFilter ); cmbFilter.ItemIndex := 0; edtWidth.setfocus; end; function TfrmResize.GetResampling: Boolean; begin Result := grpResampleOptions.Enabled; end; procedure TfrmResize.SetResampling(const Value: Boolean); begin if Value then Self.Caption := 'Resample' else Self.Caption := 'Resize'; grpResampleOptions .Enabled := Value; lblFilter .Enabled := Value; cmbFilter .Enabled := Value; chkAspectRatio .Enabled := Value; end; procedure TfrmResize.edtWidthChange(Sender: TObject); begin if Resampling and chkAspectRatio.checked and not fDontChange then begin fDontChange := true; edtHeight.text := inttostr(round(OrgHeight * strtointdef(edtWidth.text, 0) / OrgWidth)); fDontChange := false; end; end; procedure TfrmResize.edtHeightChange(Sender: TObject); begin if Resampling and chkAspectRatio.checked and not fDontChange then begin fDontChange := true; edtWidth.text := inttostr(round(OrgWidth * strtointdef(edtHeight.text, 0) / OrgHeight)); fDontChange := false; end; end; end.