Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#14

Re: Compute screen proportion

  Alt 23. Jul 2012, 10:03
Here you are

Delphi-Quellcode:
function GetScreenAspectRatio(const AWidth, AHeight: Cardinal): Single;

function LCD(v1, v2: Cardinal): Word;
begin
  Result := 0;

  if (v1 > 0) and (v2 > 0) then
  begin
    repeat
      Result := v1 mod v2;
      v1 := v2;
      v2 := Result;
    until v2 = 0;

    Result := v1;
  end;
end;

var
  Divisor: Word;
  X, Y: Cardinal;
begin
  Result := 0;
  Divisor := LCD(AWidth, AHeight);

  if Divisor <> 0 then
  begin
    X := AWidth div Divisor;
    Y := AHeight div Divisor;

    if (X = 8) and (Y = 5) then
    begin
      X := X * 2;
      Y := Y * 2;
    end;

    Result := IFF(Y <> 10, X + (Y / 10), X + (Y / 100));
  end;
end;
IFF routine you can get here (requires this).
  Mit Zitat antworten Zitat