2 #include <stdlib.h> // calloc
4 #include "swf_fill_style_array.h"
5 #include "swf_tag_shape.h"
8 swf_fill_style_array_parse(bitstream_t *bs,
9 swf_fill_style_array_t *fill_style_array,
13 swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
15 fill_style_array->count = bitstream_getbyte(bs);
17 if (swf_tag_shape->_parse_condition == SWF_TAG_SHAPE_PARSE_CONDITION_BITMAP) {
18 if (fill_style_array->count == 0) {
23 if ((tag->code != 2) && // ! DefineShape
24 (fill_style_array->count == 255)) {
25 fill_style_array->count = bitstream_getbytesLE(bs, 2);
27 fill_style_array->fill_style = calloc(fill_style_array->count, sizeof(swf_fill_style_t));
28 for (i = 0 ; i < fill_style_array->count ; i++) {
29 result = swf_fill_style_parse(bs, &(fill_style_array->fill_style[i]), tag);
31 fprintf(stderr, "swf_fill_style_array_parse: swf_fill_style_parse failed i=%d\n", i);
32 fill_style_array->count = i;
40 swf_fill_style_array_build(bitstream_t *bs,
41 swf_fill_style_array_t *fill_style_array,
45 if ((tag->code == 2) || // DefineShape
46 ((tag->code > 2) && (fill_style_array->count < 255))) {
47 // tag->code == 2 の時は count == 255 でもここに来るように
48 bitstream_putbyte(bs, fill_style_array->count);
50 bitstream_putbyte(bs, 255);
51 bitstream_putbytesLE(bs, fill_style_array->count, 2);
53 for (i = 0 ; i < fill_style_array->count ; i++) {
54 ret = swf_fill_style_build(bs, &(fill_style_array->fill_style[i]), tag);
56 fprintf(stderr, "swf_fill_style_array_build: swf_fill_style_build failed i=%d/count=%d\n", i, fill_style_array->count);
64 swf_fill_style_array_print(swf_fill_style_array_t *fill_style_array,
65 int indent_depth, swf_tag_t *tag) {
67 print_indent(indent_depth);
68 printf("fill_style_array->count=%u\n", fill_style_array->count);
69 for (i = 0 ; i < fill_style_array->count ; i++) {
70 print_indent(indent_depth);
72 swf_fill_style_print(&(fill_style_array->fill_style[i]),
73 indent_depth + 1, tag);
79 swf_fill_style_array_delete(swf_fill_style_array_t *fill_style_array) {
81 for (i = 0 ; i < fill_style_array->count ; i++) {
82 swf_fill_style_delete(&(fill_style_array->fill_style[i]));
84 free(fill_style_array->fill_style);