![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Пропорциональный размер картинки как в PhotoShop [D7, WinXP]
IrviS © (2004-03-23 13:33:00)Как-то криво все работет:
procedure TfrmResize.Edit1Change(Sender: TObject);
var NewHeight, NewWidth :Integer;
begin
if CheckBox1.Checked then
begin
NewHeight := StrToInt (Edit1.Text);
NewWidth := StrToInt (Edit2.Text);
try
NewWidth := (ValueWidth * NewHeight) div ValueHeight;
except
NewWidth := ValueWidth;
end;
Edit1.Text := IntToStr (NewHeight);
Edit2.Text := IntToStr (NewWidth);
end;
end;
procedure TfrmResize.Edit2Change(Sender: TObject);
var NewHeight, NewWidth :Integer;
begin
if CheckBox1.Checked then
begin
NewHeight := StrToInt (Edit1.Text);
NewWidth := StrToInt (Edit2.Text);
try
NewHeight := (ValueHeight * NewWidth) div ValueWidth;
except
NewHeight := ValueHeight;
end;
Edit1.Text := IntToStr (NewHeight);
Edit2.Text := IntToStr (NewWidth);
end;
end;
Думкин (2004-03-24 07:08:00) [1]
Edit1.Text := IntToStr (NewHeight);
Edit2.Text := IntToStr (NewWidth);
Данный код изменяет содержимое - вновь вызываются процедуры и т.д. Поэтому и криво.
Пусть соотношение высоты и ширины 1:2.
Вводим ширину 7, в итоге там будет четное число - 6.