![]() |
AW: Compute screen proportion
The GCD of 1366 x 768 is 2. However these displays are treated as 16:9.
|
Re: Compute screen proportion
I modified @Amateurprofi code to support x:10, changed to return float and wrote format function:
Delphi-Quellcode:
Thanks :-D
function GetScreenProportion(const AWidth, AHeight: Cardinal): string;
var AspectRatio: Single; X, Y: Extended; begin AspectRatio := GetScreenAspectRatio(AWidth, AHeight); X := Int(AspectRatio); Y := Frac(AspectRatio) * 100; if Int(Y) <> 10 then Y := Y / 10 ; Result := Format('%.0f:%.0f', [X, Y]) end; |
AW: Compute screen proportion
Please post the code for "GetScreenAspectRatio".
|
Re: Compute screen proportion
Here you are :)
Delphi-Quellcode:
IFF routine you can get
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; ![]() ![]() |
AW: Compute screen proportion
What's the result with my laptop's resolution (1366 x 768)? It should be 16:9.
|
Re: Compute screen proportion
Hm, it's a bit wrong (721:4) :o
|
AW: Compute screen proportion
You see? Use my attempt and use a higher tolerance.
|
AW: Compute screen proportion
Zitat:
|
Re: Compute screen proportion
@Furtbichler, I tested a few inputs and I see 0.45 is ok. Could you confirm?
|
AW: Compute screen proportion
![]() Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz