3 #include "swf_line_style.h"
6 swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style,
9 if (tag->code == 46) { // DefineMorphShape
10 result = bitstream_getbytesLE(bs, 2);
14 line_style->width = result;
15 line_style->width_morph = bitstream_getbytesLE(bs, 2);
16 swf_rgba_parse(bs, &(line_style->rgba));
17 swf_rgba_parse(bs, &(line_style->rgba_morph));
18 } else if (tag->code == 83 || tag->code == 84) {
19 // DefineShape4 || DefineMorphShape2
20 if (tag->code == 84) { // DefineMorphShape2
21 line_style->width_morph = bitstream_getbytesLE(bs, 2);
23 result = bitstream_getbits(bs, 2);
27 line_style->start_cap_style = result;
28 line_style->join_style = bitstream_getbits(bs, 2);
29 line_style->has_fill = bitstream_getbits(bs, 1);
30 line_style->no_hscale = bitstream_getbits(bs, 1);
31 line_style->no_vscale = bitstream_getbits(bs, 1);
32 line_style->pixel_hinting = bitstream_getbits(bs, 1);
33 line_style->reserved = bitstream_getbits(bs, 5);
34 line_style->no_close = bitstream_getbits(bs, 1);
35 line_style->end_cap_style = bitstream_getbits(bs, 2);
36 if (line_style->join_style == 2) {
37 line_style->miter_limit_factor = bitstream_getbytesLE(bs, 2);
39 if (line_style->has_fill) {
40 swf_fill_style_parse(bs, &(line_style->fill_style), tag);
42 swf_rgba_parse(bs, &(line_style->rgba));
43 if (tag->code == 84) { // DefineMorphShape2
44 swf_rgba_parse(bs, &(line_style->rgba_morph));
47 } else if (tag->code == 32) { // DefineShape3
48 result = bitstream_getbytesLE(bs, 2);
52 line_style->width = result;
53 swf_rgba_parse(bs, &(line_style->rgba));
55 result = bitstream_getbytesLE(bs, 2);
59 line_style->width = result;
60 swf_rgb_parse(bs, &(line_style->rgb));
66 swf_line_style_build(bitstream_t *bs, swf_line_style_t *line_style,
68 if (tag->code == 46) { // DefineMorphShape
69 bitstream_putbytesLE(bs, line_style->width, 2);
70 bitstream_putbytesLE(bs, line_style->width_morph, 2);
71 swf_rgba_build(bs, &(line_style->rgba));
72 swf_rgba_build(bs, &(line_style->rgba_morph));
73 } else if (tag->code == 83 || tag->code == 84) {
74 // DefineShape4 || DefineMorphShape2
75 if (tag->code == 84) { // DefineMorphShape2
76 bitstream_putbytesLE(bs, line_style->width_morph, 2);
78 bitstream_putbits(bs, line_style->start_cap_style, 2);
79 bitstream_putbits(bs, line_style->join_style, 2);
80 bitstream_putbits(bs, line_style->has_fill, 1);
81 bitstream_putbits(bs, line_style->no_hscale, 1);
82 bitstream_putbits(bs, line_style->no_vscale, 1);
83 bitstream_putbits(bs, line_style->pixel_hinting, 1);
84 bitstream_putbits(bs, line_style->reserved , 5);
85 bitstream_putbits(bs, line_style->no_close, 1);
86 bitstream_putbits(bs, line_style->end_cap_style, 2);
87 if (line_style->join_style == 2) {
88 bitstream_putbytesLE(bs, line_style->miter_limit_factor, 2);
90 if (line_style->has_fill) {
91 swf_fill_style_build(bs, &(line_style->fill_style), tag);
93 swf_rgba_build(bs, &(line_style->rgba));
94 if (tag->code == 84) { // DefineMorphShape2
95 swf_rgba_build(bs, &(line_style->rgba_morph));
98 } else if (tag->code == 32) { // DefineShape3
99 bitstream_putbytesLE(bs, line_style->width, 2);
100 swf_rgba_build(bs, &(line_style->rgba));
102 bitstream_putbytesLE(bs, line_style->width, 2);
103 swf_rgb_build(bs, &(line_style->rgb));
109 swf_line_style_print(swf_line_style_t *line_style, int indent_depth,
111 if (line_style == NULL) {
112 fprintf(stderr, "swf_line_style_print: line_style == NULL\n");
115 if (tag->code == 46) { // DefineMorphShape
116 print_indent(indent_depth);
117 printf("width=%.2f width_morph=%.2f\n",
118 (float) line_style->width / SWF_TWIPS,
119 (float) line_style->width_morph / SWF_TWIPS);
120 swf_rgba_print(&(line_style->rgba), indent_depth);
121 swf_rgba_print(&(line_style->rgba_morph), indent_depth);
122 } else if (tag->code == 83 || tag->code == 84) {
123 // DefineShape4 || DefineMorphShape2
124 if (tag->code == 84) { // DefineMorphShape2
125 print_indent(indent_depth);
126 printf("width_morph=%d\n", line_style->width_morph);
128 print_indent(indent_depth);
129 printf("start_cap_style=%u join_style=%u has_fill=%u\n",
130 line_style->start_cap_style,
131 line_style->join_style, line_style->has_fill);
132 print_indent(indent_depth);
133 printf("no_hscale=%u no_vscale=%u pixel_hinting=%u\n",
134 line_style->no_hscale, line_style->no_vscale,
135 line_style->pixel_hinting);
136 print_indent(indent_depth);
137 printf("(reserved=%u) no_close=%u end_cap_style=%u\n",
138 line_style->reserved, line_style->no_close,
139 line_style->end_cap_style);
140 if (line_style->join_style == 2) {
141 print_indent(indent_depth);
142 printf("miter_limit_factor=%u\n", line_style->miter_limit_factor);
144 if (line_style->has_fill) {
145 swf_fill_style_print(&(line_style->fill_style), indent_depth + 1,
148 swf_rgba_print(&(line_style->rgba), indent_depth);
149 if (tag->code == 84) { // DefineMorphShape2
150 swf_rgba_print(&(line_style->rgba_morph), indent_depth);
153 } else if (tag->code == 32) { // DefineShape3
154 print_indent(indent_depth);
155 printf("width=%.2f ", (float) line_style->width / SWF_TWIPS);
156 swf_rgba_print(&(line_style->rgba), 0);
158 print_indent(indent_depth);
159 printf("width=%.2f ", (float) line_style->width / SWF_TWIPS);
160 swf_rgb_print(&(line_style->rgb), 0);
166 swf_line_style_delete(swf_line_style_t *line_style) {
167 if (line_style->has_fill) {
168 swf_fill_style_delete(&(line_style->fill_style));