Nebuchadnezzar
MIS
Can you simplify this code? I know it is possible and I think there are some commands that are useable that I don´t know about so please help.
This code is ment to resize an image so it fits in a window with some controls (that's what the minus numbers are for)
procedure TFrm_Main.Hlutfallsreikningur ;
var
Ratio : double;
begin
Ratio:=(image1.Picture.height) / (image1.picture.width) ; //Calcs the ratio beetween height and width
if Frm_Main.height > Frm_Main.width then // Experimetal code
begin
image1.height:=Frm_Main.Height -100 ;
image1.width:=trunc(image1.height / Ratio);
if image1.width > Frm_Main.width -190 then
begin
image1.width:=Frm_Main.width -190 ;
image1.height:=trunc(image1.width * Ratio);
end;
end;
if Frm_Main.height <= Frm_Main.width then
begin
image1.width:=Frm_Main.width -190 ;
image1.height:=trunc(image1.width * Ratio);
if image1.height > Frm_Main.height - 100 then
begin
image1.height:=Frm_Main.height -100 ;
image1.width:=trunc(image1.height / Ratio);
end;
end;
end;
This code is ment to resize an image so it fits in a window with some controls (that's what the minus numbers are for)
procedure TFrm_Main.Hlutfallsreikningur ;
var
Ratio : double;
begin
Ratio:=(image1.Picture.height) / (image1.picture.width) ; //Calcs the ratio beetween height and width
if Frm_Main.height > Frm_Main.width then // Experimetal code
begin
image1.height:=Frm_Main.Height -100 ;
image1.width:=trunc(image1.height / Ratio);
if image1.width > Frm_Main.width -190 then
begin
image1.width:=Frm_Main.width -190 ;
image1.height:=trunc(image1.width * Ratio);
end;
end;
if Frm_Main.height <= Frm_Main.width then
begin
image1.width:=Frm_Main.width -190 ;
image1.height:=trunc(image1.width * Ratio);
if image1.height > Frm_Main.height - 100 then
begin
image1.height:=Frm_Main.height -100 ;
image1.width:=trunc(image1.height / Ratio);
end;
end;
end;