2001-10-03 14:41:53 +00:00
|
|
|
/* Stuff for correct aspect scaling. */
|
2001-10-04 11:42:21 +00:00
|
|
|
#undef ASPECT_DEBUG
|
|
|
|
|
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2001-10-03 14:41:53 +00:00
|
|
|
|
|
|
|
float monitor_aspect=4.0/3.0;
|
|
|
|
|
|
|
|
/* aspect is called with the source resolution and the
|
|
|
|
* resolution, that the scaled image should fit into
|
|
|
|
*/
|
|
|
|
|
2001-10-03 15:31:51 +00:00
|
|
|
void aspect(int *srcw, int *srch, int fitinw, int fitinh){
|
|
|
|
int srcwcp, srchcp;
|
|
|
|
srcwcp=*srcw; srchcp=*srch;
|
2001-10-03 17:40:56 +00:00
|
|
|
srcwcp=fitinw;
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect(0) fitin: %dx%d \n",fitinw,fitinh);
|
|
|
|
printf("aspect(1) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
|
|
|
|
#endif
|
2001-10-03 17:40:56 +00:00
|
|
|
srchcp=(int)(((float)fitinw / (float)*srcw * (float)*srch)
|
2001-10-04 11:42:21 +00:00
|
|
|
* ((float)fitinh / ((float)fitinw / monitor_aspect)));
|
2001-10-03 17:40:56 +00:00
|
|
|
srchcp+=srchcp%2; // round
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect(2) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
|
|
|
|
#endif
|
2001-10-03 17:40:56 +00:00
|
|
|
if(srchcp>fitinh || srchcp<*srch){
|
|
|
|
srchcp=fitinh;
|
|
|
|
srcwcp=(int)(((float)fitinh / (float)*srch * (float)*srcw)
|
2001-10-04 11:42:21 +00:00
|
|
|
* ((float)fitinw / ((float)fitinh / (1/monitor_aspect))));
|
2001-10-03 17:40:56 +00:00
|
|
|
srcwcp+=srcwcp%2; // round
|
2001-10-03 14:41:53 +00:00
|
|
|
}
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect(3) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
|
|
|
|
#endif
|
2001-10-03 17:40:56 +00:00
|
|
|
*srcw=srcwcp; *srch=srchcp;
|
2001-10-04 11:42:21 +00:00
|
|
|
#ifdef ASPECT_DEBUG
|
|
|
|
printf("aspect(4) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
|
|
|
|
#endif
|
2001-10-03 14:41:53 +00:00
|
|
|
}
|
|
|
|
|