6 "dropshadow", "blur", "glow", "bevel", "gradientglow",
7 "convolution", "colormatrix", "gradientbevel", 0
10 void swf_SetFilter(TAG
*tag
, FILTER
*filter
)
12 swf_SetU8(tag
, filter
->type
);
13 if (filter
->type
== FILTERTYPE_BLUR
) {
14 FILTER_BLUR
*f
= (FILTER_BLUR
*)filter
;
15 swf_SetFixed(tag
, f
->blurx
);
16 swf_SetFixed(tag
, f
->blury
);
17 U8 flags
= f
->passes
<< 3;
18 swf_SetU8(tag
, flags
);
19 } else if (filter
->type
== FILTERTYPE_GLOW
) {
20 FILTER_GLOW
*f
= (FILTER_GLOW
*)filter
;
21 swf_SetRGBA(tag
, &f
->rgba
);
22 swf_SetFixed(tag
, f
->blurx
);
23 swf_SetFixed(tag
, f
->blury
);
24 swf_SetFixed8(tag
, f
->strength
);
25 U8 flags
= f
->innerglow
<< 7 | f
->knockout
<< 6 | f
->composite
<< 5 | f
->passes
;
26 swf_SetU8(tag
, flags
);
27 } else if (filter
->type
== FILTERTYPE_DROPSHADOW
) {
28 FILTER_DROPSHADOW
*f
= (FILTER_DROPSHADOW
*)filter
;
29 swf_SetRGBA(tag
, &f
->color
);
30 swf_SetFixed(tag
, f
->blurx
);
31 swf_SetFixed(tag
, f
->blury
);
32 swf_SetFixed(tag
, f
->angle
);
33 swf_SetFixed(tag
, f
->distance
);
34 swf_SetFixed8(tag
, f
->strength
);
35 U8 flags
= f
->innershadow
<< 7 | f
->knockout
<< 6 | f
->composite
<< 5 | f
->passes
;
36 swf_SetU8(tag
, flags
);
37 } else if (filter
->type
== FILTERTYPE_GRADIENTGLOW
) {
38 FILTER_GRADIENTGLOW
*f
= (FILTER_GRADIENTGLOW
*)filter
;
39 swf_SetU8(tag
, f
->gradient
->num
);
42 for (s
= 0; s
< f
->gradient
->num
; s
++)
43 swf_SetRGBA(tag
, &f
->gradient
->rgba
[s
]);
44 for (s
= 0; s
< f
->gradient
->num
; s
++)
45 swf_SetU8(tag
, f
->gradient
->ratios
[s
]);
47 swf_SetFixed(tag
, f
->blurx
);
48 swf_SetFixed(tag
, f
->blury
);
49 swf_SetFixed(tag
, f
->angle
);
50 swf_SetFixed(tag
, f
->distance
);
51 swf_SetFixed8(tag
, f
->strength
);
52 U8 flags
= f
->innershadow
<< 7 | f
->knockout
<< 6 | f
->composite
<< 5 | f
->ontop
<< 4 | f
->passes
;
53 swf_SetU8(tag
, flags
);
54 } else if (filter
->type
== FILTERTYPE_BEVEL
) {
55 FILTER_BEVEL
*f
= (FILTER_BEVEL
*)filter
;
56 swf_SetRGBA(tag
, &f
->shadow
);
57 swf_SetRGBA(tag
, &f
->highlight
);
58 swf_SetFixed(tag
, f
->blurx
);
59 swf_SetFixed(tag
, f
->blury
);
60 swf_SetFixed(tag
, f
->angle
);
61 swf_SetFixed(tag
, f
->distance
);
62 swf_SetFixed8(tag
, f
->strength
);
63 U8 flags
= f
->innershadow
<< 7 | f
->knockout
<< 6 | f
->composite
<< 5 | f
->ontop
<< 4 | f
->passes
;
64 swf_SetU8(tag
, flags
);
66 fprintf(stderr
, "Writing of filter type %02x not supported yet\n", filter
->type
);
70 FILTER
*swf_GetFilter(TAG
*tag
)
72 U8 type
= swf_GetU8(tag
);
75 if (type
== FILTERTYPE_BLUR
) {
76 FILTER_BLUR
*f
= (FILTER_BLUR
*)rfx_calloc(sizeof (FILTER_BLUR
));
78 f
->blurx
= swf_GetFixed(tag
);
79 f
->blury
= swf_GetFixed(tag
);
80 U8 flags
= swf_GetU8(tag
);
81 f
->passes
= (flags
& 0xFF) >> 3;
83 } else if (type
== FILTERTYPE_GLOW
) {
84 FILTER_GLOW
*f
= (FILTER_GLOW
*)rfx_calloc(sizeof (FILTER_GLOW
));
86 swf_GetRGBA(tag
, &f
->rgba
);
87 f
->blurx
= swf_GetFixed(tag
);
88 f
->blury
= swf_GetFixed(tag
);
89 f
->strength
= swf_GetFixed8(tag
);
90 U8 flags
= swf_GetU8(tag
);
91 f
->passes
= flags
& 0x1F;
92 f
->innerglow
= (flags
>> 7) & 1;
93 f
->knockout
= (flags
>> 6) & 1;
94 f
->composite
= (flags
>> 5) & 1;
96 } else if (type
== FILTERTYPE_DROPSHADOW
) {
97 FILTER_DROPSHADOW
*f
= (FILTER_DROPSHADOW
*)rfx_calloc(sizeof (FILTER_DROPSHADOW
));
99 swf_GetRGBA(tag
, &f
->color
);
100 f
->blurx
= swf_GetFixed(tag
);
101 f
->blury
= swf_GetFixed(tag
);
102 f
->angle
= swf_GetFixed(tag
);
103 f
->distance
= swf_GetFixed(tag
);
104 f
->strength
= swf_GetFixed8(tag
);
105 U8 flags
= swf_GetU8(tag
);
106 f
->passes
= flags
& 0x1F;
107 f
->innershadow
= (flags
>> 7) & 1;
108 f
->knockout
= (flags
>> 6) & 1;
109 f
->composite
= (flags
>> 5) & 1;
111 } else if (type
== FILTERTYPE_GRADIENTGLOW
) {
112 FILTER_GRADIENTGLOW
*f
= (FILTER_GRADIENTGLOW
*)rfx_calloc(sizeof (FILTER_GRADIENTGLOW
));
114 f
->gradient
= (GRADIENT
*)rfx_calloc(sizeof (GRADIENT
));
115 f
->gradient
->num
= swf_GetU8(tag
);
116 f
->gradient
->rgba
= (RGBA
*)rfx_calloc(sizeof (RGBA
) * f
->gradient
->num
);
117 f
->gradient
->ratios
= (U8
*)rfx_calloc(sizeof (U8
) * f
->gradient
->num
);
120 for (s
= 0; s
< f
->gradient
->num
; s
++)
121 swf_GetRGBA(tag
, &f
->gradient
->rgba
[s
]);
122 for (s
= 0; s
< f
->gradient
->num
; s
++)
123 f
->gradient
->ratios
[s
] = swf_GetU8(tag
);
125 f
->blurx
= swf_GetFixed(tag
);
126 f
->blury
= swf_GetFixed(tag
);
127 f
->angle
= swf_GetFixed(tag
);
128 f
->distance
= swf_GetFixed(tag
);
129 f
->strength
= swf_GetFixed8(tag
);
130 U8 flags
= swf_GetU8(tag
);
131 f
->passes
= flags
& 0x0F;
132 f
->innershadow
= (flags
>> 7) & 1;
133 f
->knockout
= (flags
>> 6) & 1;
134 f
->composite
= (flags
>> 5) & 1;
135 f
->ontop
= (flags
>> 4) & 1;
137 } else if(type
== FILTERTYPE_BEVEL
) {
138 FILTER_BEVEL
*f
= (FILTER_BEVEL
*)rfx_calloc(sizeof (FILTER_BEVEL
));
140 swf_GetRGBA(tag
, &f
->shadow
);
141 swf_GetRGBA(tag
, &f
->highlight
);
142 f
->blurx
= swf_GetFixed(tag
);
143 f
->blury
= swf_GetFixed(tag
);
144 f
->angle
= swf_GetFixed(tag
);
145 f
->distance
= swf_GetFixed(tag
);
146 f
->strength
= swf_GetFixed8(tag
);
147 U8 flags
= swf_GetU8(tag
);
148 f
->passes
= flags
& 0x0F;
149 f
->innershadow
= (flags
>> 7) & 1;
150 f
->knockout
= (flags
>> 6) & 1;
151 f
->composite
= (flags
>> 5) & 1;
152 f
->ontop
= (flags
>> 4) & 1;
155 fprintf(stderr
, "Reading of filter type %02x not supported yet\n", type
);
161 FILTER
*swf_NewFilter(U8 type
)
165 if (type
== FILTERTYPE_BLUR
) {
166 f
= (FILTER
*)rfx_calloc(sizeof (FILTER_BLUR
));
167 memset(f
, 0, sizeof (FILTER_BLUR
));
168 } else if (type
== FILTERTYPE_GLOW
) {
169 f
= (FILTER
*)rfx_calloc(sizeof (FILTER_GLOW
));
170 memset(f
, 0, sizeof (FILTER_GLOW
));
171 } else if (type
== FILTERTYPE_DROPSHADOW
) {
172 f
= (FILTER
*)rfx_calloc(sizeof (FILTER_DROPSHADOW
));
173 memset(f
, 0, sizeof (FILTER_DROPSHADOW
));
174 } else if (type
== FILTERTYPE_GRADIENTGLOW
) {
175 f
= (FILTER
*)rfx_calloc(sizeof (FILTER_GRADIENTGLOW
));
176 memset(f
, 0, sizeof (FILTER_GRADIENTGLOW
));
177 } else if (type
== FILTERTYPE_BEVEL
) {
178 f
= (FILTER
*)rfx_calloc(sizeof (FILTER_BEVEL
));
179 memset(f
, 0, sizeof (FILTER_BEVEL
));
181 fprintf(stderr
, "Creation of filter type %02x not supported yet\n", type
);
190 void swf_DeleteFilter(FILTER
*f
)
192 if (f
->type
== FILTERTYPE_GRADIENTGLOW
&& ((FILTER_GRADIENTGLOW
*)f
)->gradient
) {
193 if (((FILTER_GRADIENTGLOW
*)f
)->gradient
->rgba
)
194 free(((FILTER_GRADIENTGLOW
*)f
)->gradient
->rgba
);
195 if (((FILTER_GRADIENTGLOW
*)f
)->gradient
->ratios
)
196 free(((FILTER_GRADIENTGLOW
*)f
)->gradient
->ratios
);
197 free(((FILTER_GRADIENTGLOW
*)f
)->gradient
);