Do you know the difference between display resolution and aspect ratio? Why do you name your thread 'screen proportion' but you refer to images?
Did you bother using google?
I found all answers.
But what the heck:
Most modern screen resulutions are not exactly 16:9, 4:3 etc.
I would recommend using a list of standard ratios, e.g. (4:3, 5:4, 16:9, 16:10), compare the screen dimension (widht / height) with the entries in the list and return the closest candidate or 'none' if the difference is out of tolerance.
Delphi-Quellcode:
Function AspectRatio (aWidth, aHeight : Integer) : String;
Const
RatioX : Array [0..3] of integer = (4,5,16,16);
RatioY : Array [0..3] of integer = (3,4,10, 9);
tolerance = 1E-2;
Var
diff,dmin, ratio : Double;
i,j : Integer;
Begin
ratio := aWidht/aHeight;
dmin := 999;
j:=-1;
for i:=0 to High(RatioX) do begin
diff := abs(RatioX[i]/RatioY[i] - ratio);
if diff < dmin then begin
j := i;
dmin := diff;
end
end;
if diff<tolerance then
result := Format('%d:%d',[RatioX[j], RatioY[j]])
else
result := 'nonstandard';
End;