[mythtv] [PATCH] Potential display aspect ratio patch for non-4:3
Chris Pinkham
cpinkham at bc2va.org
Mon Feb 2 16:01:01 EST 2004
> On 02/02/04 11:49:31, Chris Pinkham wrote:
> > So use screen resolution and pixel ratio to determine the size of the
> > bars?
>
> Use the physical dimensions of the screen to determine the aspect =20
> ratio. Nothing to do with pixels. Or, alternatively, determine DPI of =20
> X and Y separately, then figure out how many pixels you need given that =20
> DPI. However you want to think of it.
The current code uses physical dimensions to determine aspect ratio of the
screen and I wasn't talking about changing that. I said it was incorrectly
using that information when you ran in windowed mode because your window
might not be the same aspect ratio as the screen so the black bar size was
computed incorrectly. I think the 2nd solution you mentioned is the one.
How about these formulas (yDPMM unused but given for reference)::
First example shown with a 1600x900 screen that's 320x180mm w/ square pixels.
float xDPMM = pixels_wide / x_mm; 1600 / 320 = 5.0
float yDPMM = pixels_high / y_mm; 900 / 180 = 5.0
float x_mm_needed = y_mm * XJ_aspect; 180 * 4/3 = 240
int x_pix_needed = x_mm_needed * xDPMM; 240 * 5 = 1200
1200/900 = 4/3 aspect ratio
1200/1600 = 3/4 width of 16:9 screen.
dispxoff += (diswpoff - x_pix_needed) / 2; (1600 - 1200) / 2 = 200;
diswpoff = x_pix_needed; 1200 = 1200;
This equates with the current method of using 3/4 of the 16x9 screen's
width.
Now testing 1024x1024 non-square pixels w/ 320x180mm physical size.
xDPMM = 1024 / 320 = 3.2000
yDPMM = 1024 / 180 = 5.6888
x_mm_needed = 180 * 4/3 = 239.999 (say 240)
x_pix_needed = 240 * 3.2 = 768
768 / 1024 = 3/4 width of 16:9 screen.
dispxoff += (1024 - 768) / 2 = 128;
dispwoff = 768;
Now for my 1280x800 screen which is 332x208mm physical size (99% square pixel)
xDPMM = 1280 / 332 = 3.8554
yDPMM = 800 / 208 = 3.84615
x_mm_needed = 208 * 4/3 = 277.3326
x_pix_needed = 277.3326 * 3.8854 = 1077.548
1078 / 800 = ~4/3
1078 / 1280 = ~85% of 1280x800 screen (which is accurate since it's not
16:9, but more like 14.5:9)
dispxoff = (1280 - 1078) / 2 = 101
dispwoff = 1078;
--
Chris
More information about the mythtv-dev
mailing list