]> git.sesse.net Git - mlt/blobdiff - src/modules/gtk2/producer_pango.c
Add support for HTML style color parameter to producer_pango.
[mlt] / src / modules / gtk2 / producer_pango.c
index 814541b2b399028fcb100c2252d82288da3b6cef..e1bff5d43bba5a0f79942689c98eb0994752b772 100644 (file)
@@ -132,7 +132,9 @@ mlt_producer producer_pango_init( const char *filename )
                mlt_properties_set( properties, "encoding", "UTF-8" );
                mlt_properties_set_int( properties, "weight", PANGO_WEIGHT_NORMAL );
 
-               if ( filename == NULL )
+               if ( filename == NULL || ( filename && ( !strcmp( filename, "" )
+                       // workaround for old kdenlive countdown generator
+                       || strstr( filename, "<producer>" ) ) ) )
                {
                        mlt_properties_set( properties, "markup", "" );
                }
@@ -172,6 +174,7 @@ mlt_producer producer_pango_init( const char *filename )
                                item.frame = atoi( name );
                                mlt_geometry_insert( key_frames, &item );
                        }
+                       mlt_geometry_interpolate( key_frames );
                }
                else
                {
@@ -207,7 +210,10 @@ mlt_producer producer_pango_init( const char *filename )
                        }
                        else
                        {
-                               mlt_properties_set( properties, "markup", "" );
+                               producer->close = NULL;
+                               mlt_producer_close( producer );
+                               producer = NULL;
+                               free( this );
                        }
                }
 
@@ -235,20 +241,11 @@ static void set_string( char **string, const char *value, const char *fallback )
        }
 }
 
-rgba_color parse_color( char *color )
+rgba_color parse_color( char *color, unsigned int color_int )
 {
        rgba_color result = { 0xff, 0xff, 0xff, 0xff };
 
-       if ( !strncmp( color, "0x", 2 ) )
-       {
-               unsigned int temp = 0;
-               sscanf( color + 2, "%x", &temp );
-               result.r = ( temp >> 24 ) & 0xff;
-               result.g = ( temp >> 16 ) & 0xff;
-               result.b = ( temp >> 8 ) & 0xff;
-               result.a = ( temp ) & 0xff;
-       }
-       else if ( !strcmp( color, "red" ) )
+       if ( !strcmp( color, "red" ) )
        {
                result.r = 0xff;
                result.g = 0x00;
@@ -266,14 +263,12 @@ rgba_color parse_color( char *color )
                result.g = 0x00;
                result.b = 0xff;
        }
-       else
+       else if ( strcmp( color, "white" ) )
        {
-               unsigned int temp = 0;
-               sscanf( color, "%d", &temp );
-               result.r = ( temp >> 24 ) & 0xff;
-               result.g = ( temp >> 16 ) & 0xff;
-               result.b = ( temp >> 8 ) & 0xff;
-               result.a = ( temp ) & 0xff;
+               result.r = ( color_int >> 24 ) & 0xff;
+               result.g = ( color_int >> 16 ) & 0xff;
+               result.b = ( color_int >> 8 ) & 0xff;
+               result.a = ( color_int ) & 0xff;
        }
 
        return result;
@@ -377,8 +372,8 @@ static void refresh_image( mlt_frame frame, int width, int height )
 
        if ( pixbuf == NULL && property_changed )
        {
-               rgba_color fgcolor = parse_color( this->fgcolor );
-               rgba_color bgcolor = parse_color( this->bgcolor );
+               rgba_color fgcolor = parse_color( this->fgcolor, mlt_properties_get_int( producer_props, "fgcolour" ) );
+               rgba_color bgcolor = parse_color( this->bgcolor, mlt_properties_get_int( producer_props, "bgcolour" ) );
 
                if ( this->pixbuf )
                        g_object_unref( this->pixbuf );
@@ -435,7 +430,7 @@ static void refresh_image( mlt_frame frame, int width, int height )
                        interp = GDK_INTERP_NEAREST;
                else if ( strcmp( interps, "tiles" ) == 0 )
                        interp = GDK_INTERP_TILES;
-               else if ( strcmp( interps, "hyper" ) == 0 )
+               else if ( strcmp( interps, "hyper" ) == 0 || strcmp( interps, "bicubic" ) == 0 )
                        interp = GDK_INTERP_HYPER;
 
 // fprintf(stderr,"%s: scaling from %dx%d to %dx%d\n", __FILE__, this->width, this->height, width, height);
@@ -485,7 +480,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                memcpy( *buffer, gdk_pixbuf_get_pixels( this->pixbuf ), image_size );
 
                // Now update properties so we free the copy after
-               mlt_properties_set_data( properties, "image", *buffer, image_size, mlt_pool_release, NULL );
+               mlt_frame_set_image( frame, *buffer, image_size, mlt_pool_release );
                *format = mlt_image_rgb24a;
        }
        else