Ejemplo n.º 1
0
int
swf_argb_parse(bitstream_t *bs, swf_argb_t *color) {
    color->alpha = bitstream_getbyte(bs);
    color->red   = bitstream_getbyte(bs);
    color->green = bitstream_getbyte(bs);
    color->blue  = bitstream_getbyte(bs);
    return 0;
}
Ejemplo n.º 2
0
int
swf_fill_style_array_parse(bitstream_t *bs,
                           swf_fill_style_array_t *fill_style_array,
                           swf_tag_t *tag) {
    int i;
    int result;
    swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
    
    fill_style_array->count = bitstream_getbyte(bs);

    if (swf_tag_shape->_parse_condition == SWF_TAG_SHAPE_PARSE_CONDITION_BITMAP) {
        if (fill_style_array->count == 0) {
            return 1;
        }
    }
    
    if ((tag->code != 2) && // ! DefineShape
        (fill_style_array->count == 255)) {
        fill_style_array->count = bitstream_getbytesLE(bs, 2);
    }
    fill_style_array->fill_style = calloc(fill_style_array->count, sizeof(swf_fill_style_t));
    for (i = 0 ; i < fill_style_array->count ; i++) {
        result = swf_fill_style_parse(bs, &(fill_style_array->fill_style[i]), tag);
        if (result) {
            fprintf(stderr, "swf_fill_style_array_parse: swf_fill_style_parse failed i=%d\n", i);
            fill_style_array->count = i;
            return 1;
        }
    }
    return 0;
}
Ejemplo n.º 3
0
int
swf_fill_style_parse(bitstream_t *bs, swf_fill_style_t *fill_style,
                     swf_tag_t * tag) {
    swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
        
    fill_style->type = bitstream_getbyte(bs);

    if (swf_tag_shape->_parse_condition == SWF_TAG_SHAPE_PARSE_CONDITION_BITMAP) {
        if ((fill_style->type < 0x40) ||  (0x43 < fill_style->type)) {
            return 1;
        }
    }
    
    switch (fill_style->type) {
      case 0x00: // solid fill
        swf_fill_style_solid_parse(bs, &(fill_style->solid), tag);
        break;
      case 0x10: // linear gradient fill
      case 0x12: // radial gradient fill
      case 0x13: // focal  gradient fill
        swf_fill_style_gradient_parse(bs, &(fill_style->gradient), tag);
        break;
      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
        swf_fill_style_bitmap_parse(bs, &(fill_style->bitmap), tag);
        break;
    default:
        fprintf(stderr, "swf_fill_style_parse: unknown fill_style->type=0x%02x\n", fill_style->type);
        return 1;
    }
    return 0;
}
Ejemplo n.º 4
0
int
swf_action_parse(bitstream_t *bs, swf_action_t *act) {
    unsigned long offset;
    bitstream_align(bs);
    act->action_id = bitstream_getbyte(bs);
    if (act->action_id & 0x80) {
        act->action_length = bitstream_getbytesLE(bs, 2);
        offset = bitstream_getbytepos(bs);
        act->action_data = malloc(act->action_length);
        if (act->action_data == NULL) {
            fprintf(stderr, "Can't alloc memory for act->action_data\n");
            return 1;
        }
        bitstream_getstring(bs, act->action_data, act->action_length);
    }
    return 0;
}
Ejemplo n.º 5
0
int
swf_button_record_list_parse(bitstream_t *bs, swf_button_record_list_t *button_record_list, swf_tag_t *tag) {
    swf_button_record_t *prev_button_record = NULL;
    while (bitstream_getbyte(bs)) { // endflag is 0
        bitstream_incrpos(bs, -1, 0); // 1 byte back
        swf_button_record_t *button_record = malloc(sizeof(*button_record));
        button_record->next = NULL;
        if (swf_button_record_parse(bs, button_record, tag)) {
            fprintf(stderr, "swf_button_record_list_parse: swf_button_record_parse failed\n");
            free(button_record);
            break;
        }
        if (prev_button_record) {
            prev_button_record->next = button_record;
        } else {
            button_record_list->head = button_record;
        }
        prev_button_record = button_record;
    }
    return 0;
}