]> git.sesse.net Git - vlc/commitdiff
Added background color/opacity options to freetype.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 16 Jun 2011 21:02:53 +0000 (23:02 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 25 Jun 2011 18:08:26 +0000 (20:08 +0200)
modules/misc/text_renderer/freetype.c

index 0822ffbb4eced1d99c9f243d27aa3fba876a0010..5282a73b6a1b7a2cc9a5aacc55c5333a0f5eef92 100644 (file)
@@ -119,6 +119,9 @@ static void Destroy( vlc_object_t * );
     "fonts that will be rendered on the video. If absolute font size is set, "\
     "relative size will be overridden." )
 
+#define BG_OPACITY_TEXT N_("Background opacity")
+#define BG_COLOR_TEXT N_("Background color")
+
 static const int pi_sizes[] = { 20, 18, 16, 12, 6 };
 static const char *const ppsz_sizes_text[] = {
     N_("Smaller"), N_("Small"), N_("Normal"), N_("Large"), N_("Larger") };
@@ -163,6 +166,14 @@ vlc_module_begin ()
         change_integer_list( pi_color_values, ppsz_color_descriptions )
         change_safe()
 
+    add_integer_with_range( "freetype-background-opacity", 0, 0, 255,
+                            BG_OPACITY_TEXT, "", false )
+        change_safe()
+    add_integer( "freetype-background-color", 0x00000000, BG_COLOR_TEXT,
+                 "", false )
+        change_integer_list( pi_color_values, ppsz_color_descriptions )
+        change_safe()
+
     add_integer( "freetype-rel-fontsize", 16, FONTSIZER_TEXT,
                  FONTSIZER_LONGTEXT, false )
         change_integer_list( pi_sizes, ppsz_sizes_text )
@@ -225,6 +236,9 @@ struct filter_sys_t
     int            i_font_color;
     int            i_font_size;
 
+    uint8_t        i_background_opacity;
+    int            i_background_color;
+
     int            i_default_font_size;
     int            i_display_height;
     char*          psz_fontfamily;
@@ -808,10 +822,9 @@ static int RenderYUVA( filter_t *p_filter,
     p_region->fmt = fmt;
 
     /* Initialize the picture background */
-    uint32_t i_background = 0 ? 0x80000000 : 0xff000000;
-    uint8_t i_a = 0xff - ((i_background >> 24) & 0xff);
+    uint8_t i_a = p_sys->i_background_opacity;
     uint8_t i_y, i_u, i_v;
-    YUVFromRGB( i_background, &i_y, &i_u, &i_v );
+    YUVFromRGB( p_sys->i_background_color, &i_y, &i_u, &i_v );
 
     memset( p_picture->p[0].p_pixels, i_y,
             p_picture->p[0].i_pitch * p_picture->p[0].i_lines );
@@ -2205,6 +2218,11 @@ static int Create( vlc_object_t *p_this )
     p_sys->i_font_color = var_InheritInteger( p_filter, "freetype-color" );
     p_sys->i_font_color = __MAX( __MIN( p_sys->i_font_color , 0xFFFFFF ), 0 );
 
+    p_sys->i_background_opacity = var_InheritInteger( p_filter,"freetype-background-opacity" );;
+    p_sys->i_background_opacity = __MAX( __MIN( p_sys->i_background_opacity, 255 ), 0 );
+    p_sys->i_background_color = var_InheritInteger( p_filter, "freetype-background-color" );
+    p_sys->i_background_color = __MAX( __MIN( p_sys->i_background_color, 0xFFFFFF ), 0 );
+
 #ifdef WIN32
     /* Get Windows Font folder */
     wchar_t wdir[MAX_PATH];