Made to Order Software Corporation Logo

SWF Color Transform (swf_color_transform)

SWF Structure Info
Tag Flash Version: 
1
SWF Structure: 
struct swf_color_transform {
	char align;
	unsigned		f_color_has_add : 1;
	unsigned		f_color_has_mult : 1;
	unsigned		f_color_bits : 4;
	if(f_color_has_mult) {
		signed short fixed	f_color_red_mult : f_color_bits;
		signed short fixed	f_color_green_mult : f_color_bits;
		signed short fixed	f_color_blue_mult : f_color_bits;
		if(f_tag == PlaceObject2) {
			signed short fixed	f_color_alpha_mult : f_color_bits;
		}
	}
	if(f_color_has_add) {
		signed short fixed	f_color_red_add : f_color_bits;
		signed short fixed	f_color_green_add : f_color_bits;
		signed short fixed	f_color_blue_add : f_color_bits;
		if(f_tag == PlaceObject2) {
			signed short fixed	f_color_alpha_add : f_color_bits;
		}
	}
};

When the f_color_<component>_mult are not defined in the input file, use 1.0 by default. When the f_color_<component>_add are not defined in the input file, use 0.0 by default.

The factors are saved as 8.8 fixed values (divide by 256 to obtain a proper floating point value). Note that the values are limited to a signed 16 bits value. This allows for any value between -128.0 and +127.98828.

When the resulting color is defined, the multiplication is applied first as in:

	result-component = source-component * component-mult + component-add;

The result is then clamped between 0.0 and 1.0.