changeset 215:09d565842a33

font alpha resampling, see -ffactor
author arpi_esp
date Sun, 25 Mar 2001 20:38:14 +0000
parents 09d0f437b817
children 338b5664ea13
files cfg-mplayer.h libvo/font_load.c libvo/font_load.h mplayer.c
diffstat 4 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Sun Mar 25 19:10:52 2001 +0000
+++ b/cfg-mplayer.h	Sun Mar 25 20:38:14 2001 +0000
@@ -11,6 +11,7 @@
 	{"dsp", &dsp, CONF_TYPE_STRING, 0, 0, 0},
 	{"encode", &encode_name, CONF_TYPE_STRING, 0, 0, 0},
 	{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0},
+	{"ffactor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0},
 	{"bg", &play_in_bg, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nobg", &play_in_bg, CONF_TYPE_FLAG, 0, 1, 0},
 	{"sb", &seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0},
--- a/libvo/font_load.c	Sun Mar 25 19:10:52 2001 +0000
+++ b/libvo/font_load.c	Sun Mar 25 20:38:14 2001 +0000
@@ -32,7 +32,7 @@
     return raw;
 }
 
-font_desc_t* read_font_desc(char* fname){
+font_desc_t* read_font_desc(char* fname,float factor){
 unsigned char sor[1024];
 unsigned char sor2[1024];
 font_desc_t *desc;
@@ -174,6 +174,25 @@
         printf("font: Missing bitmap(s) for sub-font #%d\n",i);
         return NULL;
     }
+    if(factor!=1.0f){
+        // re-sample alpha
+        int f=factor*256.0f;
+        int size=desc->pic_a[i]->w*desc->pic_a[i]->h;
+        int j;
+        printf("font: resampling alpha by factor %5.3f (%d) ",factor,f);fflush(stdout);
+        for(j=0;j<size;j++){
+            int x=desc->pic_a[i]->bmp[j];
+            int y=desc->pic_b[i]->bmp[j];
+            
+            x=((x*f*(255-y))>>16)+y;
+            //x=(x*f)>>8;if(x<y) x=y;
+            
+            if(x<0) x=0; else
+            if(x>255) x=255;
+            desc->pic_a[i]->bmp[j]=x;
+        }
+        printf("DONE!\n");
+    }
     if(!desc->height) desc->height=desc->pic_a[i]->h;
 }
 
--- a/libvo/font_load.h	Sun Mar 25 19:10:52 2001 +0000
+++ b/libvo/font_load.h	Sun Mar 25 20:38:14 2001 +0000
@@ -20,4 +20,4 @@
 } font_desc_t;
 
 raw_file* load_raw(char *name);
-font_desc_t* read_font_desc(char* fname);
+font_desc_t* read_font_desc(char* fname,float factor);
--- a/mplayer.c	Sun Mar 25 19:10:52 2001 +0000
+++ b/mplayer.c	Sun Mar 25 20:38:14 2001 +0000
@@ -414,6 +414,7 @@
 char *conffile;
 int conffile_fd;
 char *font_name=NULL;
+float font_factor=0.75;
 #include "cfg-mplayer.h"
 
   printf("%s",banner_text);
@@ -461,7 +462,7 @@
 
 // check font
   if(font_name){
-       vo_font=read_font_desc(font_name);
+       vo_font=read_font_desc(font_name,font_factor);
        if(!vo_font) printf("Can't load font: %s\n",font_name);
   }