AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Compute screen proportion

Compute screen proportion

Ein Thema von WojTec · begonnen am 21. Jul 2012 · letzter Beitrag vom 24. Jul 2012
Antwort Antwort
Seite 2 von 2     12
Furtbichler
(Gast)

n/a Beiträge
 
#11

AW: Compute screen proportion

  Alt 22. Jul 2012, 12:53
The GCD of 1366 x 768 is 2. However these displays are treated as 16:9.
  Mit Zitat antworten Zitat
WojTec

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

Re: Compute screen proportion

  Alt 22. Jul 2012, 20:14
I modified @Amateurprofi code to support x:10, changed to return float and wrote format function:

Delphi-Quellcode:
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;
Thanks
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#13

AW: Compute screen proportion

  Alt 22. Jul 2012, 23:42
Please post the code for "GetScreenAspectRatio".
  Mit Zitat antworten Zitat
WojTec

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

Re: Compute screen proportion

  Alt 23. Jul 2012, 11: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
Furtbichler
(Gast)

n/a Beiträge
 
#15

AW: Compute screen proportion

  Alt 23. Jul 2012, 12:23
What's the result with my laptop's resolution (1366 x 768)? It should be 16:9.
  Mit Zitat antworten Zitat
WojTec

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

Re: Compute screen proportion

  Alt 23. Jul 2012, 14:18
Hm, it's a bit wrong (721:4)
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#17

AW: Compute screen proportion

  Alt 23. Jul 2012, 14:30
You see? Use my attempt and use a higher tolerance.
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#18

AW: Compute screen proportion

  Alt 23. Jul 2012, 14:40
You see? Use my attempt and use a higher tolerance.
No, your laptop has a bad physical design. It has 2/3 pixels to much in width
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
WojTec

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

Re: Compute screen proportion

  Alt 23. Jul 2012, 18:46
@Furtbichler, I tested a few inputs and I see 0.45 is ok. Could you confirm?

Geändert von WojTec (23. Jul 2012 um 19:05 Uhr)
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#20

AW: Compute screen proportion

  Alt 24. Jul 2012, 06:26
Check for yourself. To make things a bit more complicated, the link introduces pixel aspect ratio and display aspect ratio.
No, your laptop has a bad physical design. It has 2/3 pixels to much in width
Damned. Thanks god I own a jigsaw. Let me get it and cut off tho
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:06 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz