dnl
dnl PHP_SUBST(SWFED_SHARED_LIBADD)
- PHP_NEW_EXTENSION(swfed, swfed.c swf_object.c swf_header.c swf_rect.c swf_tag.c swf_tag_jpeg.c swf_tag_edit.c swf_tag_action.c swf_tag_lossless.c swf_tag_sound.c swf_tag_sprite.c swf_tag_shape.c swf_rgb.c swf_rgba.c swf_argb.c swf_xrgb.c swf_action.c swf_jpeg.c bitstream.c jpeg_segment.c swf_png.c swf_gif.c swf_shape_with_style.c swf_styles.c swf_fill_style_array.c swf_fill_style.c swf_morph_shape_with_style.c swf_fill_style_solid.c swf_fill_style_gradient.c swf_fill_style_bitmap.c swf_line_style_array.c swf_line_style.c swf_styles_count.c swf_shape_record.c swf_gradient.c swf_matrix.c swf_debug.c, $ext_shared)
+ PHP_NEW_EXTENSION(swfed, swfed.c swf_object.c swf_header.c swf_rect.c swf_tag.c swf_tag_jpeg.c swf_tag_edit.c swf_tag_action.c swf_tag_lossless.c swf_tag_sound.c swf_tag_sprite.c swf_tag_shape.c swf_rgb.c swf_rgba.c swf_argb.c swf_xrgb.c swf_action.c swf_jpeg.c bitstream.c jpeg_segment.c swf_png.c swf_gif.c swf_shape_with_style.c swf_styles.c swf_fill_style_array.c swf_fill_style.c swf_morph_shape_with_style.c swf_fill_style_solid.c swf_fill_style_gradient.c swf_fill_style_bitmap.c swf_line_style_array.c swf_line_style.c swf_styles_count.c swf_shape_record.c swf_gradient.c swf_matrix.c swf_gradient_record.c swf_debug.c, $ext_shared)
fi
swf_fill_style_bitmap_print(swf_fill_style_bitmap_t *fill_style_bitmap,
int indent_depth, swf_tag_t *tag) {
print_indent(indent_depth);
+ printf("fill_style_bitmap\n");
+ print_indent(indent_depth);
printf("bitmap_ref=%u\n", fill_style_bitmap->bitmap_ref);
swf_matrix_print(&(fill_style_bitmap->bitmap_matrix), indent_depth);
if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
if (tag->tag == 46 || tag->tag == 84) {
swf_matrix_parse(bs, &(fill_style_gradient->gradient_matrix_morph));
}
- swf_gradient_parse(bs, &(fill_style_gradient->gradient));
+ swf_gradient_parse(bs, &(fill_style_gradient->gradient), tag);
return 0;
}
int
swf_fill_style_gradient_build(bitstream_t *bs,
swf_fill_style_gradient_t *fill_style_gradient,
- swf_tag_t* tag) {
+ swf_tag_t *tag) {
swf_matrix_build(bs, &(fill_style_gradient->gradient_matrix));
// DefineMorphShape, DefineMorphShape2
if (tag->tag == 46 || tag->tag == 84) {
swf_matrix_build(bs, &(fill_style_gradient->gradient_matrix_morph));
}
- swf_gradient_build(bs, &(fill_style_gradient->gradient));
+ swf_gradient_build(bs, &(fill_style_gradient->gradient), tag);
return 0;
}
int
swf_fill_style_gradient_print(swf_fill_style_gradient_t *fill_style_gradient,
int indent_depth, swf_tag_t* tag) {
+ print_indent(indent_depth);
+ printf("fill_style_gradient\n");
swf_matrix_print(&(fill_style_gradient->gradient_matrix),
indent_depth + 1);
// DefineMorphShape, DefineMorphShape2
swf_matrix_print(&(fill_style_gradient->gradient_matrix_morph),
indent_depth + 1);
}
- swf_gradient_print(&(fill_style_gradient->gradient), indent_depth);
+ swf_gradient_print(&(fill_style_gradient->gradient), indent_depth, tag);
return 0;
}
swf_fill_style_solid_print(swf_fill_style_solid_t *fill_style_solid,
int indent_depth, swf_tag_t *tag
) {
+ print_indent(indent_depth);
+ printf("fill_style_solid\n");
if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
swf_rgba_print(&(fill_style_solid->rgba), indent_depth + 1);
swf_rgba_print(&(fill_style_solid->rgba_morph), indent_depth + 1);
#include "swf_gradient.h"
int
-swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient) {
+swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient,
+ swf_tag_t *tag) {
+ int i;
+ if (tag->tag == 83) { // DefineShape4
+ gradient->spread_mode = bitstream_getbits(bs, 2);
+ gradient->interpolation_mode = bitstream_getbits(bs, 2);
+ gradient->count = bitstream_getbits(bs, 4);
+ } else {
+ gradient->pad = bitstream_getbits(bs, 4);
+ gradient->count = bitstream_getbits(bs, 4);
+ }
+ for (i = 0 ; i < gradient->count ; i++) {
+ swf_grandient_record_parse(bs, &(gradient->gradient_record[i]));
+ gradient->focal_point = bitstream_getbytesLE(bs, 2);
+ }
return 0;
}
int
-swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient) {
+swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient,
+ swf_tag_t *tag) {
return 0;
}
int
-swf_gradient_print(swf_gradient_t *gradient, int indent_depth) {
+swf_gradient_print(swf_gradient_t *gradient, int indent_depth,
+ swf_tag_t *tag) {
print_indent(indent_depth);
return 0;
}
#ifndef __SWF_GRADIENT_H__
#define __SWF_GRADIENT_H__
+#include "swf_tag.h"
#include "swf_gradient_record.h"
typedef union swf_gradient_ {
} swf_gradient_t;
-extern int swf_gradient_parse(bitstream_t *bs, swf_gradient_t *color);
-extern int swf_gradient_build(bitstream_t *bs, swf_gradient_t *color);
-extern int swf_gradient_print(swf_gradient_t *color, int indent_depth);
+extern int swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient,
+ swf_tag_t *tag);
+extern int swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient,
+ swf_tag_t *tag);
+extern int swf_gradient_print(swf_gradient_t *gradient, int indent_depth,
+ swf_tag_t *tag);
#endif /* __SWF_GRADIENT_H__ */
--- /dev/null
+#include <stdio.h>
+#include "bitstream.h"
+#include "swf_gradient_record.h"
+
+int
+swf_gradient_record_parse(bitstream_t
+ *bs, swf_gradient_record_t *gradient_record,
+ swf_tag_t *tag) {
+ if (tag->tag == 46 || tag->tag == 84) { // DefineMorph || DefineMorphShape2
+ gradient_record->position = bitstream_getbyte(bs);
+ swf_rgba_parse(bs, &(gradient_record->rgba));
+ gradient_record->position_morph = bitstream_getbyte(bs);
+ swf_rgba_parse(bs, &(gradient_record->rgba_morph));
+ } else if (tag->tag == 32 || tag->tag == 83) {
+ // DefineShape3 || DefineShape4
+ gradient_record->position = bitstream_getbyte(bs);
+ swf_rgba_parse(bs, &(gradient_record->rgba));
+ } else {
+ gradient_record->position = bitstream_getbyte(bs);
+ swf_rgb_parse(bs, &(gradient_record->rgb));
+ }
+ return 0;
+}
+
+int
+swf_gradient_record_build(bitstream_t *bs,
+ swf_gradient_record_t *gradient_record,
+ swf_tag_t *tag) {
+ return 0;
+}
+
+int
+swf_gradient_record_print(swf_gradient_record_t *gradient_record,
+ int indent_depth, swf_tag_t *tag) {
+ print_indent(indent_depth);
+ return 0;
+}
#ifndef __SWF_GRADIENT_RECORD_H__
#define __SWF_GRADIENT_RECORD_H__
+#include "swf_tag.h"
#include "swf_rgba.h"
#include "swf_rgb.h"
swf_rgb_t rgb; // other
} swf_gradient_record_t;
-extern int swf_gradient_record_parse(bitstream_t *bs, swf_gradient_record_t *color);
-extern int swf_gradient_record_build(bitstream_t *bs, swf_gradient_record_t *color);
-extern int swf_gradient_record_print(swf_gradient_record_t *color, int indent_depth);
+extern int swf_gradient_record_parse(bitstream_t *bs,
+ swf_gradient_record_t *gradient_record,
+ swf_tag_t *tag);
+extern int swf_gradient_record_build(bitstream_t *bs,
+ swf_gradient_record_t *gradient_record,
+ swf_tag_t *tag);
+extern int swf_gradient_record_print(swf_gradient_record_t *gradient_record,
+ int indent_depth, swf_tag_t *tag);
#endif /* __SWF_GRADIENT_RECORD_H__ */
#include "bitstream.h"
#include "swf_line_style.h"
-swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style) {
- ;
+swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style,
+ swf_tag_t *tag) {
+ if (tag->tag == 46) { // DefineMorphShape
+ line_style->width = bitstream_getbytesLE(bs, 2);
+ line_style->width_morph = bitstream_getbytesLE(bs, 2);
+ swf_rgba_parse(bs, &(line_style->rgba));
+ swf_rgba_parse(bs, &(line_style->rgba_morph));
+ } else if (tag->tag == 83 || tag->tag == 84) {
+ // DefineShape4 || DefineMorphShape2
+ if (tag->tag == 84) { // DefineMorphShape2
+ line_style->width_morph = bitstream_getbytesLE(bs, 2);
+ }
+ line_style->start_cap_style = bitstream_getbits(bs, 2);
+ line_style->join_style = bitstream_getbits(bs, 2);
+ line_style->has_fill = bitstream_getbits(bs, 1);
+ line_style->no_hscale = bitstream_getbits(bs, 1);
+ line_style->no_vscale = bitstream_getbits(bs, 1);
+ line_style->pixel_hinting = bitstream_getbits(bs, 1);
+ line_style->reserved = bitstream_getbits(bs, 5);
+ line_style->no_close = bitstream_getbits(bs, 1);
+ line_style->end_cap_style = bitstream_getbits(bs, 2);
+ if (line_style->join_style == 2) {
+ line_style->miter_limit_factor = bitstream_getbytesLE(bs, 2);
+ }
+ if (line_style->has_fill) {
+ swf_fill_style_parse(bs, &(line_style->fill_style), tag);
+ } else {
+ swf_rgba_parse(bs, &(line_style->rgba));
+ if (tag->tag == 84) { // DefineMorphShape2
+ swf_rgba_parse(bs, &(line_style->rgba_morph));
+ }
+ }
+ } else if (tag->tag == 32) { // DefineShape3
+ line_style->width = bitstream_getbytesLE(bs, 2);
+ swf_rgba_parse(bs, &(line_style->rgba));
+ } else {
+ line_style->width = bitstream_getbytesLE(bs, 2);
+ swf_rgb_parse(bs, &(line_style->rgb));
+ }
return 0;
}
int
-swf_line_style_build(bitstream_t *bs, swf_line_style_t *line_style) {
+swf_line_style_build(bitstream_t *bs, swf_line_style_t *line_style,
+ swf_tag_t *tag) {
;
return 0;
}
int
-swf_line_style_print(swf_line_style_t *line_style, int indent_depth) {
+swf_line_style_print(swf_line_style_t *line_style, int indent_depth,
+ swf_tag_t *tag) {
;
return 0;
}
#ifndef __SWF_LINE_STYLE_H__
#define __SWF_LINE_STYLE_H__
+#include "swf_tag.h"
#include "swf_rgba.h"
#include "swf_fill_style.h"
#include "swf_rgb.h"
} swf_line_style_t;
-extern int swf_line_style_parse(bitstream_t *bs, swf_line_style_t *color);
-extern int swf_line_style_build(bitstream_t *bs, swf_line_style_t *color);
-extern int swf_line_style_print(swf_line_style_t *color, int indent_depth);
+extern int swf_line_style_parse(bitstream_t *bs,
+ swf_line_style_t *line_style, swf_tag_t *tag);
+extern int swf_line_style_build(bitstream_t *bs,
+ swf_line_style_t *line_style, swf_tag_t *tag);
+extern int swf_line_style_print(swf_line_style_t *line_style,
+ int indent_depth, swf_tag_t *tag);
#endif /* __SWF_LINE_STYLE_H__ */
#include <stdio.h>
+#include <stdlib.h> // calloc
#include "bitstream.h"
#include "swf_line_style_array.h"
+int
swf_line_style_array_parse(bitstream_t *bs,
- swf_line_style_array_t *line_style_array) {
- ;
+ swf_line_style_array_t *shape_with_style,
+ swf_tag_t *tag) {
+ int i;
+ shape_with_style->count = bitstream_getbyte(bs);
+ if (tag->tag != 2 || // ! DefineShape
+ shape_with_style->count == 255) {
+ shape_with_style->count = bitstream_getbytesLE(bs, 2);
+ }
+ shape_with_style->line_style = calloc(shape_with_style->count, sizeof(swf_line_style_t)); // XXX free !!! XXX
+ for (i = 0 ; i < shape_with_style->count ; i++) {
+ swf_line_style_parse(bs, &(shape_with_style->line_style[i]), tag);
+ }
return 0;
}
int
-swf_line_style_array_build(bitstream_t *bs,
- swf_line_style_array_t *line_style_array) {
- ;
- return 0;
+swf_line_style_array_build(bitstream_t *bs, swf_line_style_array_t *shape_with_style, swf_tag_t *tag) {
+ int i;
+ if (tag->tag != 2 || // ! DefineShape
+ 255 <= shape_with_style->count) {
+ bitstream_putbyte(bs, 255);
+ bitstream_putbytesLE(bs, shape_with_style->count, 2);
+ } else {
+ bitstream_putbyte(bs, shape_with_style->count);
+ }
+ for (i = 0 ; i < shape_with_style->count ; i++) {
+ swf_line_style_built(bs, &(shape_with_style->line_style[i]), tag);
+ }
}
int
-swf_line_style_array_print(swf_line_style_array_t *line_style_array,
- int indent_depth) {
- ;
+swf_line_style_array_print(swf_line_style_array_t *shape_with_style, int indent_depth, swf_tag_t *tag) {
+ int i;
+ print_indent(indent_depth);
+ printf("count=%u\n", shape_with_style->count);
+ for (i = 0 ; i < shape_with_style->count ; i++) {
+ swf_line_style_print(&(shape_with_style->line_style[i]),
+ indent_depth + 1, tag);
+ }
return 0;
}
+
+int
+swf_line_style_array_delete(swf_line_style_array_t *line_style_array) {
+ free(line_style_array->line_style);
+}
swf_line_style_t *line_style;
} swf_line_style_array_t;
-extern int swf_line_style_array_parse(bitstream_t *bs, swf_line_style_array_t *color);
-extern int swf_line_style_array_build(bitstream_t *bs, swf_line_style_array_t *color);
-extern int swf_line_style_array_print(swf_line_style_array_t *color, int indent_depth);
+extern int swf_line_style_array_parse(bitstream_t *bs,
+ swf_line_style_array_t *line_style_array,
+ swf_tag_t *tag);
+extern int swf_line_style_array_build(bitstream_t *bs,
+ swf_line_style_array_t *line_style_array,
+ swf_tag_t *tag);
+extern int swf_line_style_array_print(swf_line_style_array_t *line_style_array,
+ int indent_depth, swf_tag_t *tag);
+extern int swf_line_style_array_delete(swf_line_style_array_t *line_style_array);
#endif /* __SWF_LINE_STYLE_ARRAY_H__ */
int
swf_shape_with_style_print(swf_shape_with_style_t *shape_with_style, int indent_depth, swf_tag_t *tag) {
swf_styles_print(&(shape_with_style->styles), indent_depth, tag);
-// swf_shape_record_print(&(shape_with_style->shape_records), indent_depth);
+ swf_shape_record_print(&(shape_with_style->shape_records), indent_depth);
return 0;
}
swf_styles_parse(bitstream_t *bs, swf_styles_t *shape_with_style,
swf_tag_t *tag) {
swf_fill_style_array_parse(bs, &(shape_with_style->fill_styles), tag);
- swf_line_style_array_parse(bs, &(shape_with_style->line_styles));
+ swf_line_style_array_parse(bs, &(shape_with_style->line_styles), tag);
swf_styles_count_parse(bs, &(shape_with_style->styles_count));
return 0;
}
swf_styles_build(bitstream_t *bs, swf_styles_t *shape_with_style,
swf_tag_t *tag) {
swf_fill_style_array_build(bs, &(shape_with_style->fill_styles), tag);
- swf_line_style_array_build(bs, &(shape_with_style->line_styles));
+ swf_line_style_array_build(bs, &(shape_with_style->line_styles), tag);
swf_styles_count_build(bs, &(shape_with_style->styles_count));
return 0;
}
swf_tag_t *tag) {
swf_fill_style_array_print(&(shape_with_style->fill_styles), indent_depth,
tag);
- swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth);
+ swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth,
+ tag);
swf_styles_count_print(&(shape_with_style->styles_count), indent_depth);
return 0;
}
int
swf_styles_delete(swf_styles_t *styles) {
swf_fill_styles_array_delete(&(styles->fill_styles));
+ swf_line_styles_array_delete(&(styles->line_styles));
}
swf_tag_shape_destroy_detail(swf_tag_t *tag) {
swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
if (swf_tag_shape) {
+ swf_morph_shape_with_style_delete(&(swf_tag_shape->morph_shape_with_style));
free(swf_tag_shape);
}
return ;