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_GLOW) {
13 FILTER_GLOW*f = (FILTER_GLOW*)filter;
14 } else if(filter->type == FILTERTYPE_DROPSHADOW) {
15 FILTER_DROPSHADOW*f = (FILTER_DROPSHADOW*)filter;
16 swf_SetRGBA(tag, &f->color);
17 swf_SetFixed(tag, f->blurx);
18 swf_SetFixed(tag, f->blury);
19 swf_SetFixed(tag, f->angle);
20 swf_SetFixed(tag, f->distance);
21 swf_SetFixed8(tag, f->strength);
22 U8 flags = f->innershadow<<7|f->knockout<<6|f->composite<<5|f->passes;
23 swf_SetU8(tag, flags);
24 } else if(filter->type == FILTERTYPE_GRADIENTGLOW) {
25 FILTER_GRADIENTGLOW*f = (FILTER_GRADIENTGLOW*)filter;
26 swf_SetU8(tag, f->gradient->num);
28 for(s=0;s<f->gradient->num;s++)
29 swf_SetRGBA(tag, &f->gradient->rgba[s]);
30 for(s=0;s<f->gradient->num;s++)
31 swf_SetU8(tag, f->gradient->ratios[s]);
33 swf_SetFixed(tag, f->blurx);
34 swf_SetFixed(tag, f->blury);
35 swf_SetFixed(tag, f->angle);
36 swf_SetFixed(tag, f->distance);
37 swf_SetFixed8(tag, f->strength);
38 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
39 swf_SetU8(tag, flags);
40 } else if(filter->type == FILTERTYPE_BEVEL) {
41 FILTER_BEVEL*f = (FILTER_BEVEL*)filter;
42 swf_SetRGBA(tag, &f->shadow);
43 swf_SetRGBA(tag, &f->highlight);
44 swf_SetFixed(tag, f->blurx);
45 swf_SetFixed(tag, f->blury);
46 swf_SetFixed(tag, f->angle);
47 swf_SetFixed(tag, f->distance);
48 swf_SetFixed8(tag, f->strength);
49 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
50 swf_SetU8(tag, flags);
52 fprintf(stderr, "Writing of filter type %02x not supported yet\n", filter->type);
56 FILTER*swf_GetFilter(TAG*tag)
58 U8 type = swf_GetU8(tag);
60 if(type == FILTERTYPE_BLUR) {
61 FILTER_BLUR* f = (FILTER_BLUR*)rfx_calloc(sizeof(FILTER_BLUR));
63 f->blurx = swf_GetFixed(tag);
64 f->blury = swf_GetFixed(tag);
65 U8 flags = swf_GetU8(tag);
66 f->passes = (flags&15)<<3;
68 } else if(type == FILTERTYPE_GLOW) {
69 FILTER_GLOW* f = (FILTER_GLOW*)rfx_calloc(sizeof(FILTER_GLOW));
71 swf_GetRGBA(tag, &f->rgba);
72 f->blurx = swf_GetFixed(tag);
73 f->blury = swf_GetFixed(tag);
74 f->strength = swf_GetFixed8(tag);
75 U8 flags = swf_GetU8(tag);
77 f->innerglow = (flags>>7)&1;
78 f->knockout = (flags>>6)&1;
79 f->composite = (flags>>5)&1;
81 } else if(type == FILTERTYPE_GRADIENTGLOW) {
82 FILTER_GRADIENTGLOW* f = (FILTER_GRADIENTGLOW*)rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
84 f->gradient = (GRADIENT*)rfx_calloc(sizeof(GRADIENT));
85 f->gradient->num = swf_GetU8(tag);
86 f->gradient->rgba = (RGBA*)rfx_calloc(sizeof(RGBA)*f->gradient->num);
87 f->gradient->ratios = (U8*)rfx_calloc(sizeof(U8)*f->gradient->num);
89 for(s=0;s<f->gradient->num;s++)
90 swf_GetRGBA(tag, &f->gradient->rgba[s]);
91 for(s=0;s<f->gradient->num;s++)
92 f->gradient->ratios[s] = swf_GetU8(tag);
94 f->blurx = swf_GetFixed(tag);
95 f->blury = swf_GetFixed(tag);
96 f->angle = swf_GetFixed(tag);
97 f->distance = swf_GetFixed(tag);
98 f->strength = swf_GetFixed8(tag);
99 U8 flags = swf_GetU8(tag);
100 f->passes = flags&15;
101 f->innershadow = (flags>>7)&1;
102 f->knockout = (flags>>6)&1;
103 f->composite = (flags>>5)&1;
104 f->ontop = (flags>>4)&1;
106 } else if(type == FILTERTYPE_DROPSHADOW) {
107 FILTER_DROPSHADOW* f = (FILTER_DROPSHADOW*)rfx_calloc(sizeof(FILTER_DROPSHADOW));
109 swf_GetRGBA(tag, &f->color);
110 f->blurx = swf_GetFixed(tag);
111 f->blury = swf_GetFixed(tag);
112 f->angle = swf_GetFixed(tag);
113 f->distance = swf_GetFixed(tag);
114 f->strength = swf_GetFixed8(tag);
115 U8 flags = swf_GetU8(tag);
116 f->passes = flags&31;
117 f->innershadow = (flags>>7)&1;
118 f->knockout = (flags>>6)&1;
119 f->composite = (flags>>5)&1;
121 } else if(type == FILTERTYPE_BEVEL) {
122 FILTER_BEVEL* f = (FILTER_BEVEL*)rfx_calloc(sizeof(FILTER_BEVEL));
124 swf_GetRGBA(tag, &f->shadow);
125 swf_GetRGBA(tag, &f->highlight);
126 f->blurx = swf_GetFixed(tag);
127 f->blury = swf_GetFixed(tag);
128 f->angle = swf_GetFixed(tag);
129 f->distance = swf_GetFixed(tag);
130 f->strength = swf_GetFixed8(tag);
131 U8 flags = swf_GetU8(tag);
132 f->passes = flags&15;
133 f->innershadow = (flags>>7)&1;
134 f->knockout = (flags>>6)&1;
135 f->composite = (flags>>5)&1;
136 f->ontop = (flags>>4)&1;
139 fprintf(stderr, "Reading of filter type %02x not supported yet\n", type);
144 FILTER*swf_NewFilter(U8 type)
147 if(type == FILTERTYPE_BLUR)
148 f = (FILTER*)rfx_calloc(sizeof(FILTER_BLUR));
149 else if(type == FILTERTYPE_GRADIENTGLOW)
150 f = (FILTER*)rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
151 else if(type == FILTERTYPE_DROPSHADOW)
152 f = (FILTER*)rfx_calloc(sizeof(FILTER_DROPSHADOW));
153 else if(type == FILTERTYPE_BEVEL)
154 f = (FILTER*)rfx_calloc(sizeof(FILTER_BEVEL));
156 fprintf(stderr, "Creation of filter type %02x not supported yet\n", type);
162 void swf_DeleteFilter(FILTER*f)