--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | Author: yoya@awm.jp |
+ +----------------------------------------------------------------------+
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include "bitstream.h"
+#include "swf_tag_shape.h"
+#include "swf_object.h"
+
+swf_tag_detail_handler_t shape_detail_handler;
+
+swf_tag_detail_handler_t *
+swf_tag_shape_detail_handler(void) {
+ shape_detail_handler.create = swf_tag_shape_create_detail;
+ shape_detail_handler.input = swf_tag_shape_input_detail;
+ shape_detail_handler.identity = swf_tag_shape_identity_detail;
+ shape_detail_handler.output = swf_tag_shape_output_detail;
+ shape_detail_handler.print = swf_tag_shape_print_detail;
+ shape_detail_handler.destroy = swf_tag_shape_destroy_detail;
+ return &shape_detail_handler;
+}
+
+void *
+swf_tag_shape_create_detail(void) {
+ swf_tag_shape_detail_t *swf_tag_shape;
+ swf_tag_shape = calloc(sizeof(*swf_tag_shape), 1);
+ if (swf_tag_shape == NULL) {
+ fprintf(stderr, "ERROR: swf_tag_shape_create_detail: can't calloc\n");
+ return NULL;
+ }
+ return swf_tag_shape;
+}
+
+int
+swf_tag_shape_input_detail(swf_tag_t *tag, struct swf_object_ *swf) {
+ swf_tag_shape_detail_t *swf_tag_shape = tag->detail;
+ unsigned char *data = tag->data;
+ unsigned long length = tag->length;
+ bitstream_t *bs;
+ swf_tag_t **_tag;
+ if (swf_tag_shape == NULL) {
+ fprintf(stderr, "ERROR: swf_tag_shape_input_detail: swf_tag_shape == NULL\n");
+ return 1;
+ }
+ bs = bitstream_open();
+ bitstream_input(bs, data, length);
+ swf_tag_shape->shape_id = bitstream_getbytesLE(bs, 2);
+ bitstream_close(bs);
+ return 0;
+}
+
+int swf_tag_shape_identity_detail(swf_tag_t *tag, int id) {
+ unsigned char *data = tag->data;
+ bitstream_t *bs;
+ int shape_id;
+ if (tag->detail) {
+ swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
+ if (swf_tag_shape->shape_id == id) {
+ return 0;
+ }
+ return 1;
+ }
+ bs = bitstream_open();
+ bitstream_input(bs, data, 2);
+ shape_id = bitstream_getbytesLE(bs, 2);
+ bitstream_close(bs);
+ if (id == shape_id) {
+ return 0;
+ }
+ return 1;
+}
+
+unsigned char *
+swf_tag_shape_output_detail(swf_tag_t *tag, unsigned long *length,
+ struct swf_object_ *swf) {
+ swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
+ bitstream_t *bs;
+ unsigned char *data;
+ swf_tag_t *_tag;
+ *length = 0;
+ bs = bitstream_open();
+ bitstream_putbytesLE(bs, swf_tag_shape->shape_id, 2);
+ data = bitstream_steal(bs, length);
+ bitstream_close(bs);
+ return data;
+}
+
+void
+swf_tag_shape_print_detail(swf_tag_t *tag,
+ struct swf_object_ *swf) {
+ swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
+ int i;
+ swf_tag_t *_tag;
+ printf("\tshape_id=%d\n", swf_tag_shape->shape_id);
+ return ;
+}
+
+void
+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) {
+ free(swf_tag_shape);
+ }
+ return ;
+}
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | Author: yoya@awm.jp |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef __SWF_TAG_SHAPE__H__
+#define __SWF_TAG_SHAPE__H__
+
+#include "swf_rect.h"
+// #include "swf_morph_shape_with_style.h"
+// #include "swf_shape_with_style.h"
+#include "swf_tag.h"
+
+typedef struct swf_tag_shape_detail_ {
+ int shape_id;
+ swf_rect_t rect;
+ //
+ unsigned char is_morph:1; // DefineMorphShape, DefineMorphShape2
+ unsigned char has_strokes:1; // Defineshape4, DefineMorphShape2
+ // is_morph
+ swf_rect_t rect_morph; // MorphShape(1) or 2
+ //has_strokes
+ swf_rect_t stroke_rect; // Shape4 or MorphShape4
+ //// is_morph
+ swf_rect_t stroke_rect_morph; // & MorphShape(1) or 2
+ //
+ // 6bit reserved area
+ unsigned char define_shape_non_scaling_strokes;
+ unsigned char define_shape_scaling_strokes;
+ // is_morph
+ unsigned long offset_morph;
+// swf_morph_shape_with_style_t morph_shape_with_style;
+ // else
+// swf_shape_with_style_t morph_shape_with_style;
+} swf_tag_shape_detail_t;
+
+extern swf_tag_detail_handler_t *swf_tag_shape_detail_handler(void);
+
+extern void *swf_tag_shape_create_detail(void);
+extern int swf_tag_shape_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
+extern int swf_tag_shape_identity_detail(swf_tag_t *tag, int id);
+extern unsigned char *swf_tag_shape_output_detail(swf_tag_t *tag,
+ unsigned long *length,
+ struct swf_object_ *swf);
+extern void swf_tag_shape_print_detail(swf_tag_t *tag,
+ struct swf_object_ *swf);
+extern void swf_tag_shape_destroy_detail(swf_tag_t *tag);
+
+#endif /* __SWF_TAG_SHAPE__H__ */