return NULL;
}
+mlt_color mlt_properties_get_color( mlt_properties self, const char* name )
+{
+ mlt_profile profile = mlt_properties_get_data( self, "_profile", NULL );
+ double fps = mlt_profile_fps( profile );
+ property_list *list = self->local;
+ mlt_property value = mlt_properties_find( self, name );
+ mlt_color result = { 0xff, 0xff, 0xff, 0xff };
+ if ( value )
+ {
+ const char *color = mlt_property_get_string_l( value, list->locale );
+ unsigned int color_int = mlt_property_get_int( value, fps, list->locale );
+
+ if ( !strcmp( color, "red" ) )
+ {
+ result.r = 0xff;
+ result.g = 0x00;
+ result.b = 0x00;
+ }
+ else if ( !strcmp( color, "green" ) )
+ {
+ result.r = 0x00;
+ result.g = 0xff;
+ result.b = 0x00;
+ }
+ else if ( !strcmp( color, "blue" ) )
+ {
+ result.r = 0x00;
+ result.g = 0x00;
+ result.b = 0xff;
+ }
+ else if ( !strcmp( color, "black" ) )
+ {
+ result.r = 0x00;
+ result.g = 0x00;
+ result.b = 0x00;
+ }
+ else if ( strcmp( color, "white" ) )
+ {
+ 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;
+}
+
+
/** Get a string value by name.
*
* Do not free the returned string. It's lifetime is controlled by the property
extern void mlt_properties_lock( mlt_properties self );
extern void mlt_properties_unlock( mlt_properties self );
extern char *mlt_properties_get_time( mlt_properties, const char* name, mlt_time_format );
+extern mlt_color mlt_properties_get_color( mlt_properties, const char* name );
extern char* mlt_properties_anim_get( mlt_properties self, const char *name, int position, int length );
extern int mlt_properties_anim_set( mlt_properties self, const char *name, const char *value, int position, int length );
double w; /**< width */
double h; /**< height */
double o; /**< opacity / mix-level */
-} mlt_rect;
+}
+mlt_rect;
+
+typedef struct {
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+ uint8_t a;
+}
+mlt_color;
typedef struct mlt_frame_s *mlt_frame, **mlt_frame_ptr; /**< pointer to Frame object */
typedef struct mlt_property_s *mlt_property; /**< pointer to Property object */
return mlt_properties_get_time( get_properties(), name, format );
}
+mlt_color Properties::get_color( const char *name )
+{
+ return mlt_properties_get_color( get_properties(), name );
+}
+
char *Properties::anim_get( const char *name, int position, int length )
{
return mlt_properties_anim_get( get_properties(), name, position, length );
int set_lcnumeric( const char *locale );
const char *get_lcnumeric( );
char *get_time( const char *name, mlt_time_format = mlt_time_smpte );
+ mlt_color get_color( const char *name );
char* anim_get( const char *name, int position, int length );
int anim_set( const char *name, const char *value, int position, int length );
QCOMPARE(p.anim_get_rect("key", 25, len).y, 1.0);
}
+ void ColorFromInt()
+ {
+ Properties p;
+ p.set_lcnumeric("POSIX");
+ p.set("key", (int) 0xaabbccdd);
+ mlt_color color = p.get_color("key");
+ QCOMPARE(color.r, quint8(0xaa));
+ QCOMPARE(color.g, quint8(0xbb));
+ QCOMPARE(color.b, quint8(0xcc));
+ QCOMPARE(color.a, quint8(0xdd));
+ p.set("key", *((int*) &color));
+ QCOMPARE(p.get_int("key"), int(0xddccbbaa));
+ }
+
+ void ColorFromString()
+ {
+ Properties p;
+ p.set_lcnumeric("POSIX");
+ p.set("key", "red");
+ mlt_color color = p.get_color("key");
+ QCOMPARE(color.r, quint8(0xff));
+ QCOMPARE(color.g, quint8(0x00));
+ QCOMPARE(color.b, quint8(0x00));
+ QCOMPARE(color.a, quint8(0xff));
+ p.set("key", "#deadd00d");
+ color = p.get_color("key");
+ QCOMPARE(color.r, quint8(0xad));
+ QCOMPARE(color.g, quint8(0xd0));
+ QCOMPARE(color.b, quint8(0x0d));
+ QCOMPARE(color.a, quint8(0xde));
+ }
};
QTEST_APPLESS_MAIN(TestProperties)