AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Compute screen proportion
Thema durchsuchen
Ansicht
Themen-Optionen

Compute screen proportion

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

n/a Beiträge
 
#7

AW: Compute screen proportion

  Alt 22. Jul 2012, 07:05
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;
  Mit Zitat antworten Zitat
 


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 23:32 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