#define PF_CXFORM 0x08
#define PF_RATIO 0x10
#define PF_NAME 0x20
-#define PF_CLIPACTION 0x40
+#define PF_CLIPDEPTH 0x40
#define PF_ACTIONEVENT 0x80
+#define PF2_FILTERS 0x01
+#define PF2_BLENDMODE 0x02
+#define PF2_ASBITMAP 0x04
+//...
+
+char*blendModeNames[] = {"normal","normal2","layer","multiply",
+ "screen","lighten", "darken","add",
+ "substract","difference","invert","alpha",
+ "erase","overlay","hardlight",0};
+
int isUnitMatrix(MATRIX* m)
{
/* a matrix with all zeros is also considered
return 0;
}
-int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name)
-{ U8 flags;
+static int objectplace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction, U8 blendmode, FILTERLIST*filters)
+{ U8 flags,flags2;
if (!t) return -1;
if(cx && id && cx->r1==0 && cx->g1==0 && cx->b1==0 && cx->a1==0
if(m && id && isUnitMatrix(m))
m = 0;
- flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|((m||cx)&&(!id)?PF_MOVE:0);
+ flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|((m||cx)&&(!id)?PF_MOVE:0)|(clipaction?PF_CLIPDEPTH:0);
+ flags2 = (0?PF2_ASBITMAP:0)|(blendmode?PF2_BLENDMODE:0)|(filters?PF2_FILTERS:0);
swf_SetU8(t,flags);
+ if(t->id == ST_PLACEOBJECT3)
+ swf_SetU8(t, flags2);
swf_SetU16(t,depth);
if (flags&PF_CHAR) swf_SetU16(t,id);
if (flags&PF_MATRIX) swf_SetMatrix(t,m);
if (flags&PF_CXFORM) swf_SetCXForm(t,cx,1);
if (flags&PF_RATIO) swf_SetU16(t,0);
+ /* ??? The spec states that name comes first? */
+ if (flags&PF_CLIPDEPTH) swf_SetU16(t, clipaction);
if (flags&PF_NAME) swf_SetString(t,name);
-
+
+ if (flags2&PF2_BLENDMODE)
+ swf_SetU8(t,blendmode);
return 0;
}
-
+int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name)
+{
+ return objectplace(t,id,depth,m,cx,name,0,0,0);
+}
int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction)
-{ U8 flags;
- if (!t) return -1;
-
- if(cx && cx->r1==0 && cx->g1==0 && cx->b1==0 && cx->a1==0
- && cx->r0==256 && cx->g0==256 && cx->b0==256 && cx->a0==256)
- cx = 0;
-
- if(m && isUnitMatrix(m))
- m = 0;
-
- flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|
- ((m||cx)&&(!id)?PF_MOVE:0)|(clipaction?PF_CLIPACTION:0);
-
- swf_SetU8(t,flags);
- swf_SetU16(t,depth);
- if (flags&PF_CHAR) swf_SetU16(t,id);
- if (flags&PF_MATRIX) swf_SetMatrix(t,m);
- if (flags&PF_CXFORM) swf_SetCXForm(t,cx,1);
- if (flags&PF_RATIO) swf_SetU16(t,0);
-
- /* ??? The spec states that name comes first? */
- if (flags&PF_CLIPACTION) swf_SetU16(t, clipaction);
- if (flags&PF_NAME) swf_SetString(t,name);
- return 0;
+{
+ return objectplace(t,id,depth,m,cx,name,clipaction,0,0);
+}
+int swf_ObjectPlaceBlend(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U8 blend)
+{
+ if(t->id != ST_PLACEOBJECT3)
+ fprintf(stderr, "wrong tag- ignoring blend mode\n");
+ return objectplace(t,id,depth,m,cx,name,0,blend,0);
}
-
int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx)
-{ return swf_ObjectPlace(t,0,depth,m,cx,NULL);
+{
+ return objectplace(t,0,depth,m,cx,0,0,0,0);
}
void swf_SetPlaceObject(TAG * t,SWFPLACEOBJECT* obj)
{
- U8 flags;
if (!t) return ;
if(t->id == ST_PLACEOBJECT) {
swf_SetU16(t, obj->id);
swf_SetMatrix(t, &obj->matrix);
swf_SetCXForm(t, &obj->cxform, 0);
} else {
+ U8 flags,flags2;
int m = !isUnitMatrix(&obj->matrix);
int cx = !isUnitCXForm(&obj->cxform);
flags = (obj->id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(obj->ratio?PF_RATIO:0)|
(obj->name?PF_NAME:0)|(obj->move?PF_MOVE:0)|
- (obj->clipdepth?PF_CLIPACTION:0);
+ (obj->clipdepth?PF_CLIPDEPTH:0);
+ flags2 = (0?PF2_ASBITMAP:0)|(obj->blendmode?PF2_BLENDMODE:0)|(obj->filters?PF2_FILTERS:0);
swf_SetU8(t,flags);
+ if(t->id == ST_PLACEOBJECT2)
+ swf_SetU8(t,flags2);
swf_SetU16(t,obj->depth);
if (flags&PF_CHAR) swf_SetU16(t,obj->id);
if (flags&PF_MATRIX) swf_SetMatrix(t,&obj->matrix);
if (flags&PF_RATIO) swf_SetU16(t,obj->ratio);
/* ??? The spec states that name comes first? */
- if (flags&PF_CLIPACTION) swf_SetU16(t,obj->clipdepth);
+ if (flags&PF_CLIPDEPTH) swf_SetU16(t,obj->clipdepth);
if (flags&PF_NAME) swf_SetString(t,obj->name);
+
+ if (flags2&PF2_FILTERS) {
+ // ...
+ }
+ if (flags2&PF2_BLENDMODE)
+ swf_SetU8(t,obj->blendmode);
if (flags&PF_ACTIONEVENT) {
// ...
}
void swf_GetPlaceObject(TAG * tag,SWFPLACEOBJECT* obj)
{
- U8 flags;
if(!tag) {
memset(obj, 0, sizeof(SWFPLACEOBJECT));
swf_GetMatrix(0, &obj->matrix);
swf_GetMatrix(tag, &obj->matrix);
swf_GetCXForm(tag, &obj->cxform, 0);
//obj->internal = PF_CHAR|PF_MATRIX|PF_CXFORM;
- } else if(tag->id == ST_PLACEOBJECT2) {
+ } else if(tag->id == ST_PLACEOBJECT2 || tag->id == ST_PLACEOBJECT3) {
+ U8 flags,flags2=0;
flags = swf_GetU8(tag);
+ if(tag->id == ST_PLACEOBJECT3)
+ flags2 = swf_GetU8(tag);
memset(obj,0,sizeof(SWFPLACEOBJECT));
swf_GetMatrix(0,&obj->matrix);
obj->depth = swf_GetU16(tag);
//obj->internal = flags;
- if(flags&1) obj->move = 1;
- if(flags&2) obj->id = swf_GetU16(tag);
- if(flags&4) swf_GetMatrix(tag, &obj->matrix);
- if(flags&8) swf_GetCXForm(tag, &obj->cxform,1);
- if(flags&16) obj->ratio = swf_GetU16(tag);
+ if(flags&PF_MOVE) obj->move = 1;
+ if(flags&PF_CHAR) obj->id = swf_GetU16(tag);
+ if(flags&PF_MATRIX) swf_GetMatrix(tag, &obj->matrix);
+ if(flags&PF_CXFORM) swf_GetCXForm(tag, &obj->cxform,1);
+ if(flags&PF_RATIO) obj->ratio = swf_GetU16(tag);
/* if you modify the order of these operations, also
modify it in ../src/swfcombine.c */
- if(flags&64)
+ if(flags&PF_CLIPDEPTH)
obj->clipdepth = swf_GetU16(tag); //clip
- if(flags&32) {
+ if(flags&PF_NAME) {
int l,t;
U8*data;
swf_ResetReadBits(tag);
obj->name = data;
while((data[t++] = swf_GetU8(tag)));
}
+ if(flags2&PF2_BLENDMODE) {
+ obj->blendmode = swf_GetU8(tag);
+ }
/* Actionscript ignored (for now) */
obj->actions = 0;