annotate libvo/aspect.c @ 2053:720ca9249e4e

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