svnno****@sourc*****
svnno****@sourc*****
2011年 3月 7日 (月) 23:21:37 JST
Revision: 391 http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=391 Author: yoya Date: 2011-03-07 23:21:37 +0900 (Mon, 07 Mar 2011) Log Message: ----------- - shape_bitmap_get_refcid を実装 - shape_bitmap_replace_refcid を実装 (shape_bitmap_identity を削除) Modified Paths: -------------- trunk/src/php_swfed.c trunk/src/swf_object.c trunk/src/swf_tag_shape.c trunk/src/swf_tag_shape.h -------------- next part -------------- Modified: trunk/src/php_swfed.c =================================================================== --- trunk/src/php_swfed.c 2011-03-07 14:00:14 UTC (rev 390) +++ trunk/src/php_swfed.c 2011-03-07 14:21:37 UTC (rev 391) @@ -664,7 +664,7 @@ i = 0; for (tag = swf->tag ; tag ; tag=tag->next) { register int tag_code = tag->tag; - if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_identity(tag, bitmap_id) == 0)) { + if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_get_cid(tag) == bitmap_id)) { swf_tag_shape_detail_t *swf_tag_shape = tag->detail; add_index_long(return_value, i, (long) swf_tag_shape->shape_id); i++; Modified: trunk/src/swf_object.c =================================================================== --- trunk/src/swf_object.c 2011-03-07 14:00:14 UTC (rev 390) +++ trunk/src/swf_object.c 2011-03-07 14:21:37 UTC (rev 391) @@ -429,7 +429,7 @@ height_scale = (double) old_height / new_height; for (tag = swf->tag ; tag ; tag=tag->next) { register int tag_code = tag->tag; - if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_identity(tag, bitmap_id) == 0)) { + if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_get_refcid(tag) == bitmap_id)) { swf_tag_shape_detail_t *swf_tag_shape = tag->detail; swf_tag_apply_shape_matrix_factor(tag, swf_tag_shape->shape_id, @@ -444,7 +444,7 @@ height_scale = (double) new_height / old_height; for (tag = swf->tag ; tag ; tag=tag->next) { register int tag_code = tag->tag; - if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_identity(tag, bitmap_id) == 0)) { + if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_get_refcid(tag) == bitmap_id)) { swf_tag_shape_detail_t *swf_tag_shape = tag->detail; swf_tag_apply_shape_rect_factor(tag, swf_tag_shape->shape_id, width_scale, height_scale, @@ -455,7 +455,7 @@ if (swf->shape_adjust_mode & SWFED_SHAPE_BITMAP_TYPE_TILLED) { for (tag = swf->tag ; tag ; tag=tag->next) { register int tag_code = tag->tag; - if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_identity(tag, bitmap_id) == 0)) { + if (isShapeTag(tag_code) && (swf_tag_shape_bitmap_get_refcid(tag) == bitmap_id)) { swf_tag_shape_detail_t *swf_tag_shape = tag->detail; swf_tag_apply_shape_type_tilled(tag, swf_tag_shape->shape_id, swf); } Modified: trunk/src/swf_tag_shape.c =================================================================== --- trunk/src/swf_tag_shape.c 2011-03-07 14:00:14 UTC (rev 390) +++ trunk/src/swf_tag_shape.c 2011-03-07 14:21:37 UTC (rev 391) @@ -137,15 +137,63 @@ return 0; // always 0 } -int swf_tag_shape_bitmap_identity(swf_tag_t *tag, int bitmap_id) { +int swf_tag_shape_bitmap_get_refcid(swf_tag_t *tag) { swf_tag_shape_detail_t *swf_tag_shape; int i, ret; if (tag == NULL) { - fprintf(stderr, "swf_tag_shape_bitmap_identity: tag == NULL\n"); + fprintf(stderr, "swf_tag_shape_bitmap_get_refcid: tag == NULL\n"); + return -1; + } + if (! isShapeTag(tag->tag)) { + fprintf(stderr, "swf_tag_shape_bitmap_get_refcid: ! isShapeTag(%d)\n", + tag->tag); + return -1; + } + if (tag->detail == NULL) { + tag->detail = swf_tag_shape_create_detail(); + swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail; + swf_tag_shape->_parse_condition = SWF_TAG_SHAPE_PARSE_CONDITION_BITMAP; + ret = swf_tag_shape_input_detail(tag, NULL); + if (ret) { + swf_tag_shape_destroy_detail(tag); + return -1; // no shape bitmap + } + } else { + swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail; + } + // + for (i = 0 ; i < swf_tag_shape->shape_with_style.styles.fill_styles.count ; i++) { + swf_fill_style_t *fill_style; + fill_style = &(swf_tag_shape->shape_with_style.styles.fill_styles.fill_style[i]); + if (fill_style == NULL) { + fprintf(stderr, "swf_tag_shape_bitmap_get_refcid: fill_style == NULL i=%d\n", i); + return -1; // Illegal!!! + } + switch (fill_style->type) { + case 0x40: // tilled bitmap fill with smoothed edges + case 0x41: // clipped bitmap fill with smoothed edges + case 0x42: // tilled bitmap fill with hard edges + case 0x43: // clipped bitmap fill with hard edges + if (fill_style->bitmap.bitmap_ref != 0xffff) { + return fill_style->bitmap.bitmap_ref; + } + break; + default: + break; + } + } + return -1; // not found +} + +int swf_tag_shape_bitmap_replace_refcid(swf_tag_t *tag, int cid) { + swf_tag_shape_detail_t *swf_tag_shape; + int i, ret; + if (tag == NULL) { + fprintf(stderr, "swf_tag_shape_bitmap_replace_refcid: tag == NULL\n"); return 1; } if (! isShapeTag(tag->tag)) { - fprintf(stderr, "swf_tag_shape_bitmap_identity: ! isShapeTag(%d)\n", + fprintf(stderr, "swf_tag_shape_bitmap_replace_refcid: ! isShapeTag(%d)\n", tag->tag); return 1; } @@ -166,7 +214,7 @@ swf_fill_style_t *fill_style; fill_style = &(swf_tag_shape->shape_with_style.styles.fill_styles.fill_style[i]); if (fill_style == NULL) { - fprintf(stderr, "swf_tag_shape_bitmap_identity: fill_style == NULL i=%d\n", i); + fprintf(stderr, "swf_tag_shape_bitmap_replace_refcid: fill_style == NULL i=%d\n", i); return 1; // Illegal!!! } switch (fill_style->type) { @@ -174,8 +222,14 @@ case 0x41: // clipped bitmap fill with smoothed edges case 0x42: // tilled bitmap fill with hard edges case 0x43: // clipped bitmap fill with hard edges - if (fill_style->bitmap.bitmap_ref == bitmap_id) { - return 0; // found + if (fill_style->bitmap.bitmap_ref != 0xffff) { + fill_style->bitmap.bitmap_ref = cid; + if (tag->data) { + // 内容が変わったので元データは削除 + free(tag->data); + tag->data = NULL; + } + return 0; // success! } break; default: @@ -185,7 +239,6 @@ return 1; // not found } - unsigned char * swf_tag_shape_output_detail(swf_tag_t *tag, unsigned long *length, struct swf_object_ *swf) { Modified: trunk/src/swf_tag_shape.h =================================================================== --- trunk/src/swf_tag_shape.h 2011-03-07 14:00:14 UTC (rev 390) +++ trunk/src/swf_tag_shape.h 2011-03-07 14:21:37 UTC (rev 391) @@ -50,7 +50,8 @@ extern int swf_tag_shape_input_detail(swf_tag_t *tag, struct swf_object_ *swf); extern int swf_tag_shape_get_cid_detail(swf_tag_t *tag); extern int swf_tag_shape_replace_cid_detail(swf_tag_t *tag, int id); -extern int swf_tag_shape_bitmap_identity(swf_tag_t *tag, int bitmap_id); +extern int swf_tag_shape_bitmap_get_refcid(swf_tag_t *tag); +extern int swf_tag_shape_bitmap_replace_refcid(swf_tag_t *tag, int cid); extern unsigned char *swf_tag_shape_output_detail(swf_tag_t *tag, unsigned long *length, struct swf_object_ *swf);