1 char* filtername[] = {"dropshadow","blur","glow","bevel","gradientglow","convolution","colormatrix","gradientbevel", 0};
3 void swf_SetFilter(TAG*tag, FILTER*filter)
5 swf_SetU8(tag, filter->type);
6 if(filter->type == FILTERTYPE_BLUR) {
7 FILTER_BLUR*f = (FILTER_BLUR*)filter;
8 swf_SetFixed(tag, f->blurx);
9 swf_SetFixed(tag, f->blury);
10 U8 flags = f->passes << 3;
11 swf_SetU8(tag, flags);
12 } else if(filter->type == FILTERTYPE_DROPSHADOW) {
13 FILTER_DROPSHADOW*f = (FILTER_DROPSHADOW*)filter;
14 swf_SetRGBA(tag, &f->color);
15 swf_SetFixed(tag, f->blurx);
16 swf_SetFixed(tag, f->blury);
17 swf_SetFixed(tag, f->angle);
18 swf_SetFixed(tag, f->distance);
19 swf_SetFixed8(tag, f->strength);
20 U8 flags = f->innershadow<<7|f->knockout<<6|f->composite<<5|f->passes;
21 swf_SetU8(tag, flags);
22 } else if(filter->type == FILTERTYPE_GRADIENTGLOW) {
23 FILTER_GRADIENTGLOW*f = (FILTER_GRADIENTGLOW*)filter;
24 swf_SetU8(tag, f->gradient->num);
26 for(s=0;s<f->gradient->num;s++)
27 swf_SetRGBA(tag, &f->gradient->rgba[s]);
28 for(s=0;s<f->gradient->num;s++)
29 swf_SetU8(tag, f->gradient->ratios[s]);
31 swf_SetFixed(tag, f->blurx);
32 swf_SetFixed(tag, f->blury);
33 swf_SetFixed(tag, f->angle);
34 swf_SetFixed(tag, f->distance);
35 swf_SetFixed8(tag, f->strength);
36 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
37 swf_SetU8(tag, flags);
38 } else if(filter->type == FILTERTYPE_BEVEL) {
39 FILTER_BEVEL*f = (FILTER_BEVEL*)filter;
40 swf_SetRGBA(tag, &f->shadow);
41 swf_SetRGBA(tag, &f->highlight);
42 swf_SetFixed(tag, f->blurx);
43 swf_SetFixed(tag, f->blury);
44 swf_SetFixed(tag, f->angle);
45 swf_SetFixed(tag, f->distance);
46 swf_SetFixed8(tag, f->strength);
47 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
48 swf_SetU8(tag, flags);
50 fprintf(stderr, "Writing of filter type %02x not supported yet\n", filter->type);
54 FILTER*swf_GetFilter(TAG*tag)
56 U8 type = swf_GetU8(tag);
58 if(type == FILTERTYPE_BLUR) {
59 FILTER_BLUR* f = rfx_calloc(sizeof(FILTER_BLUR));
61 f->blurx = swf_GetFixed(tag);
62 f->blury = swf_GetFixed(tag);
63 U8 flags = swf_GetU8(tag);
64 f->passes = (flags&15)<<3;
66 } else if(type == FILTERTYPE_GRADIENTGLOW) {
67 FILTER_GRADIENTGLOW* f = rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
69 f->gradient = rfx_calloc(sizeof(GRADIENT));
70 f->gradient->num = swf_GetU8(tag);
71 f->gradient->rgba = rfx_calloc(sizeof(RGBA)*f->gradient->num);
72 f->gradient->ratios = rfx_calloc(sizeof(U8)*f->gradient->num);
74 for(s=0;s<f->gradient->num;s++)
75 swf_GetRGBA(tag, &f->gradient->rgba[s]);
76 for(s=0;s<f->gradient->num;s++)
77 f->gradient->ratios[s] = swf_GetU8(tag);
79 f->blurx = swf_GetFixed(tag);
80 f->blury = swf_GetFixed(tag);
81 f->angle = swf_GetFixed(tag);
82 f->distance = swf_GetFixed(tag);
83 f->strength = swf_GetFixed8(tag);
84 U8 flags = swf_GetU8(tag);
86 f->innershadow = (flags>>7)&1;
87 f->knockout = (flags>>6)&1;
88 f->composite = (flags>>5)&1;
89 f->ontop = (flags>>4)&1;
91 } else if(type == FILTERTYPE_DROPSHADOW) {
92 FILTER_DROPSHADOW* f = rfx_calloc(sizeof(FILTER_DROPSHADOW));
94 swf_GetRGBA(tag, &f->color);
95 f->blurx = swf_GetFixed(tag);
96 f->blury = swf_GetFixed(tag);
97 f->angle = swf_GetFixed(tag);
98 f->distance = swf_GetFixed(tag);
99 f->strength = swf_GetFixed8(tag);
100 U8 flags = swf_GetU8(tag);
101 f->passes = flags&31;
102 f->innershadow = (flags>>7)&1;
103 f->knockout = (flags>>6)&1;
104 f->composite = (flags>>5)&1;
106 } else if(type == FILTERTYPE_BEVEL) {
107 FILTER_BEVEL* f = rfx_calloc(sizeof(FILTER_BEVEL));
109 swf_GetRGBA(tag, &f->shadow);
110 swf_GetRGBA(tag, &f->highlight);
111 f->blurx = swf_GetFixed(tag);
112 f->blury = swf_GetFixed(tag);
113 f->angle = swf_GetFixed(tag);
114 f->distance = swf_GetFixed(tag);
115 f->strength = swf_GetFixed8(tag);
116 U8 flags = swf_GetU8(tag);
117 f->passes = flags&15;
118 f->innershadow = (flags>>7)&1;
119 f->knockout = (flags>>6)&1;
120 f->composite = (flags>>5)&1;
121 f->ontop = (flags>>4)&1;
124 fprintf(stderr, "Reading of filter type %02x not supported yet\n", type);
129 FILTER*swf_NewFilter(U8 type)
132 if(type == FILTERTYPE_BLUR)
133 f = rfx_calloc(sizeof(FILTER_BLUR));
134 else if(type == FILTERTYPE_GRADIENTGLOW)
135 f = rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
136 else if(type == FILTERTYPE_DROPSHADOW)
137 f = rfx_calloc(sizeof(FILTER_DROPSHADOW));
138 else if(type == FILTERTYPE_BEVEL)
139 f = rfx_calloc(sizeof(FILTER_BEVEL));
141 fprintf(stderr, "Creation of filter type %02x not supported yet\n", type);