OSDN Git Service

care newstyle on bitmap repeat
authorYoshihiro Yamazaki <yoya@awm.jp>
Wed, 1 Aug 2012 12:14:40 +0000 (21:14 +0900)
committerYoshihiro Yamazaki <yoya@awm.jp>
Wed, 1 Aug 2012 12:14:40 +0000 (21:14 +0900)
src/swf_tag_shape.c

index 95cb735..2cb365a 100644 (file)
@@ -594,6 +594,9 @@ int
 swf_tag_shape_apply_type_tilled(void *detail, int shape_id, int bitmap_id) {
     int i, count;
     swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) detail;
+    swf_fill_style_array_t *fill_styles;;
+    swf_shape_record_t *shape_record = NULL;
+
     if (detail == NULL) {
         fprintf(stderr, "swf_tag_shape_apply_type_tilled: detail == NULL\n");
         return 1;
@@ -603,20 +606,48 @@ swf_tag_shape_apply_type_tilled(void *detail, int shape_id, int bitmap_id) {
              shape_id, swf_tag_shape->shape_id);
         return 1;
     }
-    count = swf_tag_shape->shape_with_style.styles.fill_styles.count;
-    for (i = 0 ; i < count ; i++) {
-        swf_fill_style_t *fill_style = &(swf_tag_shape->shape_with_style.styles.fill_styles.fill_style[i]);
-        switch (fill_style->type) {
-          case 0x41: // clipped bitmap fill with smoothed edges
-            if ((bitmap_id < 0) || (bitmap_id == fill_style->bitmap.bitmap_ref)) {
-                fill_style->type = 0x40; // tilled  bitmap fill with smoothed edges
+
+    fill_styles = &(swf_tag_shape->shape_with_style.styles.fill_styles);
+
+    if (! swf_tag_shape->is_morph) {
+        shape_record = &(swf_tag_shape->shape_with_style.shape_records);
+    }
+
+    while (fill_styles) {
+        for (i = 0 ; i < fill_styles->count; i++) {
+            swf_fill_style_t *fill_style = &(fill_styles->fill_style[i]);
+            switch (fill_style->type) {
+            case 0x41: // clipped bitmap fill with smoothed edges
+                if ((bitmap_id < 0) || (bitmap_id == fill_style->bitmap.bitmap_ref)) {
+                    fill_style->type = 0x40; // tilled  bitmap fill with smoothed edges
+                }
+                break;
+            case 0x43: // clipped bitmap fill with hard edges
+                if ((bitmap_id < 0) || (bitmap_id == fill_style->bitmap.bitmap_ref)) {
+                    fill_style->type = 0x42; // tilled  bitmap fill with hard edges
+                }
+                break;
             }
-            break;
-          case 0x43: // clipped bitmap fill with hard edges
-            if ((bitmap_id < 0) || (bitmap_id == fill_style->bitmap.bitmap_ref)) {
-                fill_style->type = 0x42; // tilled  bitmap fill with hard edges
+        }
+        fill_styles = NULL;
+        while (shape_record) {
+            int first_bit = (shape_record->first_6bits >> 5) & 1;
+            int next_5bits = shape_record->first_6bits & 0x1f;
+            if (first_bit == 0) {
+                if ((next_5bits == 0)) { // end record
+                    shape_record = NULL;
+                    break; // end
+                } else { // setup record
+                    if (shape_record->shape.shape_setup.shape_has_new_styles) {
+                        fill_styles = &(shape_record->shape.shape_setup.styles.fill_styles);
+                        shape_record = shape_record->next;
+                        break; // next loop
+                    }
+                    shape_record = shape_record->next;
+                }
+            } else { // edge record
+                shape_record = shape_record->next;
             }
-            break;
         }
     }
     return 0;