Einzelnen Beitrag anzeigen

Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#4

AW: Aspect ratio berechnen

  Alt 6. Jul 2011, 13:32
Äh?! Jup!
Delphi-Quellcode:
// Hier mal eine Version für D2010 aufwärts
TAspectRatio = record
  X, Y: Integer;
  procedure CalcRatio(const XRes, YRes: Integer);
end;

procedure TAspectRatio.CalcRatio(const XRes, YRes: Integer);
var
  GGT: Integer;
begin
  GGT := GetGGT(XRes, YRes);
  X := XRes div GGT;
  Y := YRes div GGT;
end;

// Oder das ganze für D2009 und älter
TAspectRatio = record
  X, Y: Integer;
end;

function GetAspectRatio(const XRes, YRes: Integer): TAspectRatio;
var
  GGT: Integer;
begin
  GGT := GetGGT(XRes, YRes);
  Result.X := XRes div GGT;
  Result.Y := YRes div GGT;
end;
Die Methode GetGGT musst dir halt irgendwo im Netz suchen
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat