X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_property.c;h=7cbb6819a2b9c0aa0f1a0823340dd9bbe5a5c364;hb=f4963a6aa07644399b273b5d2b1f9299c9047414;hp=b657bf827698a2587d8b94ee209e8f39034a65e0;hpb=461a447d3b38516f101a346dcb5e8ad0cb8a6927;p=melted diff --git a/src/framework/mlt_property.c b/src/framework/mlt_property.c index b657bf8..7cbb681 100644 --- a/src/framework/mlt_property.c +++ b/src/framework/mlt_property.c @@ -246,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 @@ -254,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. + 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 ); + { + return strtoul( value + 2, NULL, 16 ); + } else + { return strtol( value, NULL, 10 ); + } } /** Get the property as an integer. @@ -405,7 +427,7 @@ char *mlt_property_get_string( mlt_property this ) { this->types |= mlt_prop_string; this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%lld", this->prop_int64 ); + sprintf( this->prop_string, "%lld", (long long int)this->prop_int64 ); } else if ( this->types & mlt_prop_data && this->serialiser != NULL ) {