[Swfed-svn] swfed-svn [547] DefineMorphShape のバイナリを構築する時に、offset_morph を更新する処理を追加

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 7日 (木) 23:30:28 JST


Revision: 547
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=547
Author:   yoya
Date:     2011-04-07 23:30:28 +0900 (Thu, 07 Apr 2011)

Log Message:
-----------
DefineMorphShape のバイナリを構築する時に、offset_morph を更新する処理を追加

Modified Paths:
--------------
    trunk/src/swf_morph_shape_with_style.c
    trunk/src/swf_morph_shape_with_style.h
    trunk/src/swf_tag_shape.c


-------------- next part --------------
Modified: trunk/src/swf_morph_shape_with_style.c
===================================================================
--- trunk/src/swf_morph_shape_with_style.c	2011-04-07 13:47:33 UTC (rev 546)
+++ trunk/src/swf_morph_shape_with_style.c	2011-04-07 14:30:28 UTC (rev 547)
@@ -13,7 +13,7 @@
         fprintf(stderr, "swf_morph_shape_with_style_parse: swf_shape_record_parse shape_records failed\n");
         return ret;
     }
-    
+
     bitstream_align(bs);
     swf_styles_count_parse(bs, &(morph_shape_with_style->styles_count));
     ret = swf_shape_record_parse(bs, &(morph_shape_with_style->shape_records_morph),
@@ -31,7 +31,10 @@
                                  swf_tag_t *tag) {
     swf_styles_build(bs, &(morph_shape_with_style->styles), tag);
     swf_shape_record_build(bs, &(morph_shape_with_style->shape_records), tag);
+
     bitstream_align(bs);
+    morph_shape_with_style->offset_of_end_edges = bitstream_getbytepos(bs);
+
     swf_styles_count_build(bs, &(morph_shape_with_style->styles_count));
     swf_shape_record_build(bs, &(morph_shape_with_style->shape_records_morph),
                            tag);

Modified: trunk/src/swf_morph_shape_with_style.h
===================================================================
--- trunk/src/swf_morph_shape_with_style.h	2011-04-07 13:47:33 UTC (rev 546)
+++ trunk/src/swf_morph_shape_with_style.h	2011-04-07 14:30:28 UTC (rev 547)
@@ -17,6 +17,9 @@
     // char align;
     swf_styles_count_t styles_count;
     swf_shape_record_t shape_records_morph;
+
+    // offset_morph の計算に必要
+    long offset_of_end_edges;
 } swf_morph_shape_with_style_t;
 
 extern int swf_morph_shape_with_style_parse(bitstream_t *bs,

Modified: trunk/src/swf_tag_shape.c
===================================================================
--- trunk/src/swf_tag_shape.c	2011-04-07 13:47:33 UTC (rev 546)
+++ trunk/src/swf_tag_shape.c	2011-04-07 14:30:28 UTC (rev 547)
@@ -109,6 +109,7 @@
         swf_tag_shape->define_shape_scaling_strokes = bitstream_getbits(bs, 1);
     }
     if (swf_tag_shape->is_morph) {
+        bitstream_align(bs);
         swf_tag_shape->offset_morph = bitstream_getbytesLE(bs, 4);
         ret = swf_morph_shape_with_style_parse(bs, &swf_tag_shape->morph_shape_with_style, tag);
         if (ret) {
@@ -358,6 +359,9 @@
     unsigned char *data;
     int ret;
     (void) swf;
+    long offset_of_offset_morph = 0;
+    long tmp_offset_byte = 0;
+    long tmp_offset_bit = 0;
     *length = 0;
     // build context
     swf_tag_shape->_current_fill_style_num = 0;
@@ -403,8 +407,19 @@
         bitstream_putbits(bs, 1, swf_tag_shape->define_shape_scaling_strokes);
     }
     if (swf_tag_shape->is_morph) {
-        bitstream_putbytesLE(bs, 4, swf_tag_shape->offset_morph);
+        bitstream_align(bs);
+        // 後で上書きするので、offset を覚えておく
+        offset_of_offset_morph = bitstream_getbytepos(bs);
+        bitstream_putbytesLE(bs, swf_tag_shape->offset_morph, 4);
         swf_morph_shape_with_style_build(bs, &swf_tag_shape->morph_shape_with_style, tag);
+        // offset_morph のフィールドに戻って上書きする
+        // offset_morph の後ろからの offset 差なので、- 4 する
+        swf_tag_shape->offset_morph = swf_tag_shape->morph_shape_with_style.offset_of_end_edges - offset_of_offset_morph - 4;
+        tmp_offset_byte = bitstream_getbytepos(bs); // offset を退避
+        tmp_offset_bit = bitstream_getbitpos(bs);
+        bitstream_setpos(bs, offset_of_offset_morph, 0);
+        bitstream_putbytesLE(bs, swf_tag_shape->offset_morph , 4);
+        bitstream_setpos(bs, tmp_offset_byte, tmp_offset_bit); // 元に戻す
     } else {
         ret = swf_shape_with_style_build(bs, &swf_tag_shape->shape_with_style, tag);
         if (ret) {
@@ -427,7 +442,7 @@
     print_indent(indent_depth);
     printf("shape_id=%d\n", swf_tag_shape->shape_id);
     swf_rect_print(&(swf_tag_shape->rect), indent_depth);
-    print_indent(indent_depth);
+//    print_indent(indent_depth);
 //    printf("is_morph=%d has_strokes=%d\n",
 //           swf_tag_shape->is_morph, swf_tag_shape->has_strokes);
     if (swf_tag_shape->is_morph) {



Swfed-svn メーリングリストの案内
Back to archive index