comparison libvo/aspect.c @ 2053:720ca9249e4e

Monitor aspect stuff.
author atmos4
date Wed, 03 Oct 2001 14:41:53 +0000
parents
children f5146118777e
comparison
equal deleted inserted replaced
2052:9af96cfbe175 2053:720ca9249e4e
1 /* Stuff for correct aspect scaling. */
2 #include "aspect.h"
3
4 float monitor_aspect=4.0/3.0;
5
6 /* aspect is called with the source resolution and the
7 * resolution, that the scaled image should fit into
8 */
9
10 rect_t aspect(int srcw, int srch, int fitinw, int fitinh){
11 rect_t r,z;
12 r.w=fitinw;
13 r.x=0;
14 r.h=(int)(((float)fitinw / (float)srcw * (float)srch)
15 * ((float)fitinh/((float)fitinw/monitor_aspect)));
16 r.h+=r.h%2; // round
17 r.y=(fitinh-r.h)/2;
18 z=r;
19 //printf("aspect rez x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
20 if(r.h>fitinh || r.h<srch){
21 r.h=fitinh;
22 r.y=0;
23 r.w=(int)(((float)fitinh / (float)srch * (float)srcw)
24 * ((float)fitinw/((float)fitinh/(1/monitor_aspect))));
25 r.w+=r.w%2; // round
26 r.x=(fitinw-r.w)/2;
27 }
28 if(r.w>fitinw) r=z;
29 //printf("aspect ret x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
30 return r;
31 }
32