// from swftools.c:
void enumerateUsedIDs_styles(TAG * tag, void (*callback)(TAG*, int, void*), void*callback_data, int num, int morph);
-static void parseFillStyleArray(TAG*tag, SHAPE2*shape)
+static int parseFillStyleArray(TAG*tag, SHAPE2*shape)
{
U16 count;
int t;
num = 2;
else if(tag->id == ST_DEFINESHAPE3)
num = 3;
+ else if(tag->id == ST_DEFINESHAPE4)
+ num = 4;
count = swf_GetU8(tag);
if(count == 0xff && num>1) // defineshape2,3 only
shape->fillstyles[t].type = type;
if(type == 0) {
/* plain color */
- if(num == 3)
+ if(num >= 3)
swf_GetRGBA(tag, &dest->color);
else
swf_GetRGB(tag, &dest->color);
for(t=linestylestart;t<shape->numlinestyles;t++)
{
shape->linestyles[t].width = swf_GetU16(tag);
- if(num == 3)
+
+ if(num >= 4) {
+ U16 flags = swf_GetU16(tag);
+ if(flags & 0x2000)
+ swf_GetU16(tag); // miter limit
+ if(flags & 0x0800) {
+ fprintf(stderr, "Filled strokes parsing not yet supported\n");
+ return 0;
+ }
+ }
+
+ if(num >= 3)
swf_GetRGBA(tag, &shape->linestyles[t].color);
else
swf_GetRGB(tag, &shape->linestyles[t].color);
}
}
- return;
+ return 1;
}
} else {
linestyleadd = shape2->numlinestyles;
fillstyleadd = shape2->numfillstyles;
- parseFillStyleArray(tag, shape2);
+ if(!parseFillStyleArray(tag, shape2))
+ return 0;
}
fillbits = swf_GetBits(tag, 4);
linebits = swf_GetBits(tag, 4);
swf_ShapeSetEnd(tag);
shape->data = tag->data;
shape->bitlen = tag->len*8;
+ free(tag);
}
void swf_SetShape2(TAG*tag, SHAPE2*shape2)
num = 2;
else if(tag->id == ST_DEFINESHAPE3)
num = 3;
+ else if(tag->id == ST_DEFINESHAPE4)
+ num = 4;
else {
fprintf(stderr, "parseDefineShape must be called with a shape tag");
}
memset(shape, 0, sizeof(SHAPE2));
shape->bbox = rfx_alloc(sizeof(SRECT));
swf_GetRect(tag, shape->bbox);
+ if(num>=4) {
+ SRECT r2;
+ swf_ResetReadBits(tag);
+ swf_GetRect(tag, &r2); // edge bounds
+ U8 flags = swf_GetU8(tag); // flags, &1: contains scaling stroke, &2: contains non-scaling stroke
+ }
- parseFillStyleArray(tag, shape);
+ if(!parseFillStyleArray(tag, shape)) {
+ return;
+ }
swf_ResetReadBits(tag);
fill = (U16)swf_GetBits(tag,4);
l = shape->lines;
}
+static void free_lines(SHAPELINE* lines)
+{
+ if (lines->next)
+ free_lines(lines->next);
+ free(lines);
+}
+
void swf_RecodeShapeData(U8*data, int bitlen, int in_bits_fill, int in_bits_line,
U8**destdata, U32*destbitlen, int out_bits_fill, int out_bits_line)
{
swf_Shape2ToShape(&s2,&s);
+ free_lines(s2.lines);
free(s2.fillstyles);
free(s2.linestyles);
free(s.fillstyle.data);