X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_property.c;h=e09c019c0c38541f16478ade9fca4a68351097d7;hb=35f66808e0975cced8fc3f70e993b6cd7eec5800;hp=d64592f2f090ebeb516c509db2a641cca4163aae;hpb=e5fd66367b6f976e3bcb0ada98408afcb40cb2ce;p=melted diff --git a/src/framework/mlt_property.c b/src/framework/mlt_property.c index d64592f..e09c019 100644 --- a/src/framework/mlt_property.c +++ b/src/framework/mlt_property.c @@ -1,8 +1,9 @@ /** * \file mlt_property.c * \brief Property class definition + * \see mlt_property_s * - * Copyright (C) 2003-2008 Ushodaya Enterprises Limited + * Copyright (C) 2003-2009 Ushodaya Enterprises Limited * \author Charles Yates * * This library is free software; you can redistribute it and/or @@ -245,6 +246,15 @@ int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destr * * The string must begin with '0x' to be interpreted as hexadecimal. * Otherwise, it is interpreted as base 10. + * If the string begins with '#' it is interpreted as a hexadecimal color value + * in the form RRGGBB or AARRGGBB. Color values that begin with '0x' are + * always in the form RRGGBBAA where the alpha components are not optional. + * Applications and services should expect the binary color value in bytes to + * be in the following order: RGBA. This means they will have to cast the int + * to an unsigned int. This is especially important when they need to shift + * right to obtain RGB without alpha in order to make it do a logical instead + * of arithmetic shift. + * * \private \memberof mlt_property_s * \param value a string to convert * \return the resultant integer @@ -253,10 +263,23 @@ static inline int mlt_property_atoi( const char *value ) { if ( value == NULL ) return 0; + // Parse a hex color value as #RRGGBB or #AARRGGBB. + else if ( value[0] == '#' ) + { + unsigned int rgb = strtoul( value + 1, NULL, 16 ); + unsigned int alpha = ( strlen( value ) > 7 ) ? ( rgb >> 24 ) : 0xff; + return ( rgb << 8 ) | alpha; + } + // Do hex and decimal explicitly to avoid decimal value with leading zeros + // interpreted as octal. else if ( value[0] == '0' && value[1] == 'x' ) + { return strtol( value + 2, NULL, 16 ); + } else + { return strtol( value, NULL, 10 ); + } } /** Get the property as an integer. @@ -427,7 +450,7 @@ char *mlt_property_get_string( mlt_property this ) * destructor function. * \public \memberof mlt_property_s * \param this a property - * \param[out] length the size of the binary object in bytes + * \param[out] length the size of the binary object in bytes (optional) * \return an opaque data pointer or NULL if not available */