Hi there, I'm resizing images, or I have a dialog that does.
I would like to work out when setting say the width how to then proportionally set the height to keep the aspect.
I'm using this code
function ProportionalSize(phisicalsize,newsize:tpoint):Tpoint;
var
Percent : single;
tempx,tempy : Single;
fs:tpoint;
begin
if phisicalsize.x<>0 then
tempx:=((newsize.x)/phisicalsize.x)*100
else tempx:=0;
If Phisicalsize.y<>0 then
tempy:=((newsize.y)/phisicalsize.y)*100
else Tempy:=0;
if tempx<=tempy then
percent:=tempx
else
percent:=tempy;
fs.x:=trunc((phisicalsize.x/100)*percent);
fs.y:=trunc((phisicalsize.y/100)*percent);
result:=fs;
end;
// Then this to work out the height when changing the width.
procedure TfrmDLGImageResize.seWidthChange(Sender: TObject);
var
os, ns, ps : TPoint;
begin
if FNoChange then exit;
os.x := intImageWidth;
os.y := intImageHeight;
ns.x := intImageWidth;
ns.y := seHeight.value;
FNoChange := true;
ps := ProportionalSize(os, ns);
seHeight.value := ps.y;
FNoChange := false;
end;
It doesn't rightly work, I'm curious if anyone is willing to lend their math aid. I'm afaid I am really quite rotten at it. I post this here since it's for bgra.Resample. I just wanted the dialog that set's the sizes to be able to work out the say height proportional to the width when setting the value.
Please, any help with this would be marvellous, if this is really in the wrong place I do humbly apologise.
CJ