]> git.sesse.net Git - vlc/commitdiff
Overlay - Added text demonstrations
authorSøren Bøg <avacore@videolan.org>
Mon, 20 Aug 2007 09:02:24 +0000 (11:02 +0200)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 9 Apr 2008 08:42:20 +0000 (10:42 +0200)
Overlay - Added text demonstrations

extras/misc/overlay-test.c

index 0d8189e935357b90d0c07b1e31cbe64d23d15cd4..01d14fe41e1dd789046a878472a367c0c160a20e 100644 (file)
@@ -141,6 +141,29 @@ void SetVisibility( FILE *p_cmd, FILE *p_res, int i_overlay, int i_visible ) {
                     i_visible );
 }
 
+void SetTextAlpha( FILE *p_cmd, FILE *p_res, int i_overlay, int i_alpha ) {
+    CheckedCommand( p_cmd, p_res, "SetTextAlpha %d %d\n", i_overlay, i_alpha );
+}
+
+void SetTextColor( FILE *p_cmd, FILE *p_res, int i_overlay, int i_red,
+                   int i_green, int i_blue ) {
+    CheckedCommand( p_cmd, p_res, "SetTextColor %d %d %d %d\n", i_overlay,
+                    i_red, i_green, i_blue );
+}
+
+void SetTextSize( FILE *p_cmd, FILE *p_res, int i_overlay, int i_size ) {
+    CheckedCommand( p_cmd, p_res, "SetTextSize %d %d\n", i_overlay, i_size );
+}
+
+int GetTextSize( FILE *p_cmd, FILE *p_res, int i_overlay ) {
+    int i_size;
+
+    CheckedCommand( p_cmd, p_res, "GetTextSize %d\n", i_overlay );
+    fscanf( p_res, "%d", &i_size );
+
+    return i_size;
+}
+
 /*****************************************************************************
  * Test Routines
  *****************************************************************************/
@@ -181,6 +204,47 @@ void BasicTest( FILE *p_cmd, FILE *p_res, int i_overlay ) {
     sleep( 5 );
 }
 
+void TextTest( FILE *p_cmd, FILE *p_res, int i_overlay ) {
+    printf( "Sweeping (text) alpha..." );
+    for( int i_alpha = 0xFF; i_alpha >= -0xFF ; i_alpha -= 8 ) {
+        SetTextAlpha( p_cmd, p_res, i_overlay, abs( i_alpha ) );
+        usleep( 20000 );
+    }
+    SetTextAlpha( p_cmd, p_res, i_overlay, 255 );
+    printf( " done\n" );
+
+    printf( "Sweeping colors..." );
+    for( int i_red = 0xFF; i_red >= 0x00 ; i_red -= 8 ) {
+        SetTextColor( p_cmd, p_res, i_overlay, i_red, 0xFF, 0xFF );
+        usleep( 20000 );
+    }
+    for( int i_green = 0xFF; i_green >= 0x00 ; i_green -= 8 ) {
+        SetTextColor( p_cmd, p_res, i_overlay, 0x00, i_green, 0xFF );
+        usleep( 20000 );
+    }
+    for( int i_blue = 0xFF; i_blue >= 0x00 ; i_blue -= 8 ) {
+        SetTextColor( p_cmd, p_res, i_overlay, 0x00, 0x00, i_blue );
+        usleep( 20000 );
+    }
+    SetTextColor( p_cmd, p_res, i_overlay, 0x00, 0x00, 0x00 );
+    printf( " done\n" );
+
+    printf( "Getting size..." );
+    int i_basesize = GetTextSize( p_cmd, p_res, i_overlay );
+    printf( " done. Size is %d\n", i_basesize );
+
+    printf( "Sweeping size..." );
+    for( float f_theta = 0; f_theta <= M_PI ; f_theta += M_PI / 128.0 ) {
+        SetTextSize( p_cmd, p_res, i_overlay,
+                     i_basesize * ( 1 + 3 * sin( f_theta ) ) );
+        usleep( 20000 );
+    }
+    SetTextSize( p_cmd, p_res, i_overlay, i_basesize );
+    printf( " done\n" );
+
+    sleep( 5 );
+}
+
 /*****************************************************************************
  * main
  *****************************************************************************/
@@ -280,6 +344,7 @@ int main( int i_argc, char *ppsz_argv[] ) {
 
     BasicTest( p_cmd, p_res, i_overlay_image );
     BasicTest( p_cmd, p_res, i_overlay_text );
+    TextTest( p_cmd, p_res, i_overlay_text );
 
     DeleteImage( p_cmd, p_res, i_overlay_image );
     DeleteImage( p_cmd, p_res, i_overlay_text );