5 char* filtername[] = {"dropshadow","blur","glow","bevel","gradientglow","convolution","colormatrix","gradientbevel", 0};
7 void swf_SetFilter(TAG*tag, FILTER*filter)
9 swf_SetU8(tag, filter->type);
10 if(filter->type == FILTERTYPE_BLUR) {
11 FILTER_BLUR*f = (FILTER_BLUR*)filter;
12 swf_SetFixed(tag, f->blurx);
13 swf_SetFixed(tag, f->blury);
14 U8 flags = f->passes << 3;
15 swf_SetU8(tag, flags);
16 } else if(filter->type == FILTERTYPE_GLOW) {
17 FILTER_GLOW*f = (FILTER_GLOW*)filter;
18 } else if(filter->type == FILTERTYPE_DROPSHADOW) {
19 FILTER_DROPSHADOW*f = (FILTER_DROPSHADOW*)filter;
20 swf_SetRGBA(tag, &f->color);
21 swf_SetFixed(tag, f->blurx);
22 swf_SetFixed(tag, f->blury);
23 swf_SetFixed(tag, f->angle);
24 swf_SetFixed(tag, f->distance);
25 swf_SetFixed8(tag, f->strength);
26 U8 flags = f->innershadow<<7|f->knockout<<6|f->composite<<5|f->passes;
27 swf_SetU8(tag, flags);
28 } else if(filter->type == FILTERTYPE_GRADIENTGLOW) {
29 FILTER_GRADIENTGLOW*f = (FILTER_GRADIENTGLOW*)filter;
30 swf_SetU8(tag, f->gradient->num);
32 for(s=0;s<f->gradient->num;s++)
33 swf_SetRGBA(tag, &f->gradient->rgba[s]);
34 for(s=0;s<f->gradient->num;s++)
35 swf_SetU8(tag, f->gradient->ratios[s]);
37 swf_SetFixed(tag, f->blurx);
38 swf_SetFixed(tag, f->blury);
39 swf_SetFixed(tag, f->angle);
40 swf_SetFixed(tag, f->distance);
41 swf_SetFixed8(tag, f->strength);
42 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
43 swf_SetU8(tag, flags);
44 } else if(filter->type == FILTERTYPE_BEVEL) {
45 FILTER_BEVEL*f = (FILTER_BEVEL*)filter;
46 swf_SetRGBA(tag, &f->shadow);
47 swf_SetRGBA(tag, &f->highlight);
48 swf_SetFixed(tag, f->blurx);
49 swf_SetFixed(tag, f->blury);
50 swf_SetFixed(tag, f->angle);
51 swf_SetFixed(tag, f->distance);
52 swf_SetFixed8(tag, f->strength);
53 U8 flags = f->passes|f->innershadow<<7|f->knockout<<6|f->composite<<5|f->ontop<<4;
54 swf_SetU8(tag, flags);
56 fprintf(stderr, "Writing of filter type %02x not supported yet\n", filter->type);
60 FILTER*swf_GetFilter(TAG*tag)
62 U8 type = swf_GetU8(tag);
64 if(type == FILTERTYPE_BLUR) {
65 FILTER_BLUR* f = (FILTER_BLUR*)rfx_calloc(sizeof(FILTER_BLUR));
67 f->blurx = swf_GetFixed(tag);
68 f->blury = swf_GetFixed(tag);
69 U8 flags = swf_GetU8(tag);
70 f->passes = (flags&15)<<3;
72 } else if(type == FILTERTYPE_GLOW) {
73 FILTER_GLOW* f = (FILTER_GLOW*)rfx_calloc(sizeof(FILTER_GLOW));
75 swf_GetRGBA(tag, &f->rgba);
76 f->blurx = swf_GetFixed(tag);
77 f->blury = swf_GetFixed(tag);
78 f->strength = swf_GetFixed8(tag);
79 U8 flags = swf_GetU8(tag);
81 f->innerglow = (flags>>7)&1;
82 f->knockout = (flags>>6)&1;
83 f->composite = (flags>>5)&1;
85 } else if(type == FILTERTYPE_GRADIENTGLOW) {
86 FILTER_GRADIENTGLOW* f = (FILTER_GRADIENTGLOW*)rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
88 f->gradient = (GRADIENT*)rfx_calloc(sizeof(GRADIENT));
89 f->gradient->num = swf_GetU8(tag);
90 f->gradient->rgba = (RGBA*)rfx_calloc(sizeof(RGBA)*f->gradient->num);
91 f->gradient->ratios = (U8*)rfx_calloc(sizeof(U8)*f->gradient->num);
93 for(s=0;s<f->gradient->num;s++)
94 swf_GetRGBA(tag, &f->gradient->rgba[s]);
95 for(s=0;s<f->gradient->num;s++)
96 f->gradient->ratios[s] = swf_GetU8(tag);
98 f->blurx = swf_GetFixed(tag);
99 f->blury = swf_GetFixed(tag);
100 f->angle = swf_GetFixed(tag);
101 f->distance = swf_GetFixed(tag);
102 f->strength = swf_GetFixed8(tag);
103 U8 flags = swf_GetU8(tag);
104 f->passes = flags&15;
105 f->innershadow = (flags>>7)&1;
106 f->knockout = (flags>>6)&1;
107 f->composite = (flags>>5)&1;
108 f->ontop = (flags>>4)&1;
110 } else if(type == FILTERTYPE_DROPSHADOW) {
111 FILTER_DROPSHADOW* f = (FILTER_DROPSHADOW*)rfx_calloc(sizeof(FILTER_DROPSHADOW));
113 swf_GetRGBA(tag, &f->color);
114 f->blurx = swf_GetFixed(tag);
115 f->blury = swf_GetFixed(tag);
116 f->angle = swf_GetFixed(tag);
117 f->distance = swf_GetFixed(tag);
118 f->strength = swf_GetFixed8(tag);
119 U8 flags = swf_GetU8(tag);
120 f->passes = flags&31;
121 f->innershadow = (flags>>7)&1;
122 f->knockout = (flags>>6)&1;
123 f->composite = (flags>>5)&1;
125 } else if(type == FILTERTYPE_BEVEL) {
126 FILTER_BEVEL* f = (FILTER_BEVEL*)rfx_calloc(sizeof(FILTER_BEVEL));
128 swf_GetRGBA(tag, &f->shadow);
129 swf_GetRGBA(tag, &f->highlight);
130 f->blurx = swf_GetFixed(tag);
131 f->blury = swf_GetFixed(tag);
132 f->angle = swf_GetFixed(tag);
133 f->distance = swf_GetFixed(tag);
134 f->strength = swf_GetFixed8(tag);
135 U8 flags = swf_GetU8(tag);
136 f->passes = flags&15;
137 f->innershadow = (flags>>7)&1;
138 f->knockout = (flags>>6)&1;
139 f->composite = (flags>>5)&1;
140 f->ontop = (flags>>4)&1;
143 fprintf(stderr, "Reading of filter type %02x not supported yet\n", type);
148 FILTER*swf_NewFilter(U8 type)
151 if(type == FILTERTYPE_BLUR)
152 f = (FILTER*)rfx_calloc(sizeof(FILTER_BLUR));
153 else if(type == FILTERTYPE_GRADIENTGLOW)
154 f = (FILTER*)rfx_calloc(sizeof(FILTER_GRADIENTGLOW));
155 else if(type == FILTERTYPE_DROPSHADOW)
156 f = (FILTER*)rfx_calloc(sizeof(FILTER_DROPSHADOW));
157 else if(type == FILTERTYPE_BEVEL)
158 f = (FILTER*)rfx_calloc(sizeof(FILTER_BEVEL));
160 fprintf(stderr, "Creation of filter type %02x not supported yet\n", type);
166 void swf_DeleteFilter(FILTER*f)