Example #1
0
void write_changepos(TAG*output, TAG*tag, int movex, int movey, float scalex, float scaley, int scalepos)
{
    if(movex || movey || scalex != 1.0 || scaley != 1.0)
    {
	switch(tag->id)
	{
	    case ST_PLACEOBJECT2: {
		MATRIX m;
		U8 flags;
		swf_GetMatrix(0, &m);
		tag->pos = 0;
		tag->readBit = 0;

		flags = swf_GetU8(tag);
		swf_SetU8(output, flags|4);
		swf_SetU16(output, swf_GetU16(tag)); //depth
		//flags&1: move
		if(flags&2) {
		    swf_SetU16(output, swf_GetU16(tag)); //id
		}
		// flags & 4
		if(flags&4) {
		    swf_GetMatrix(tag, &m);
		} else {
		    swf_GetMatrix(0, &m);
		}
		matrix_adjust(&m, movex, movey, scalex, scaley, scalepos);
		swf_SetMatrix(output, &m);

		if (tag->readBit)  { tag->pos++; tag->readBit = 0; } //swf_ResetReadBits(tag);

		swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos);
		break;
	    }
	    case ST_PLACEOBJECT: {
		MATRIX m;
		swf_SetU16(output, swf_GetU16(tag)); //id
		swf_SetU16(output, swf_GetU16(tag)); //depth
		
		swf_GetMatrix(tag, &m);
		matrix_adjust(&m, movex, movey, scalex, scaley, scalepos);
		swf_SetMatrix(output, &m);
		
		if (tag->readBit)  { tag->pos++; tag->readBit = 0; } //swf_ResetReadBits(tag);

		swf_SetBlock(output, &tag->data[tag->pos], tag->len - tag->pos);
		break;
	    }
	    default:
	    swf_SetBlock(output, tag->data, tag->len);
	}
    } 
    else 
    {
	    swf_SetBlock(output, tag->data, tag->len);
    }
}
Example #2
0
void changedepth(TAG*tag, int add)
{
    if(tag->id == ST_PLACEOBJECT)
	PUT16(&tag->data[2],GET16(&tag->data[2])+add);
    if(tag->id == ST_PLACEOBJECT2)
	PUT16(&tag->data[1],GET16(&tag->data[1])+add);
    if(tag->id == ST_REMOVEOBJECT)
	PUT16(&tag->data[2],GET16(&tag->data[2])+add);
    if(tag->id == ST_REMOVEOBJECT2)
	PUT16(&tag->data[0],GET16(&tag->data[0])+add);
    if(tag->id == ST_PLACEOBJECT2) {
	SWFPLACEOBJECT obj;
	U8 flags;
	swf_SetTagPos(tag, 0);
	flags = swf_GetU8(tag);
	if(flags&2) swf_GetU16(tag); //id
	if(flags&4) swf_GetMatrix(tag, 0);
	if(flags&8) swf_GetCXForm(tag, 0,1);
	if(flags&16) swf_GetU16(tag); //ratio
	if(flags&64) {
	    swf_ResetReadBits(tag);
	    printf("%d->%d\n", GET16(&tag->data[tag->pos]),
		               GET16(&tag->data[tag->pos])+add);
	    PUT16(&tag->data[tag->pos],GET16(&tag->data[tag->pos])+add);
	}
	msg("<warning> Depth relocation not fully working yet with clipdepths", tag->id);
    }
}
Example #3
0
PyObject* f_Matrix(PyObject* _self, PyObject* args, PyObject* kwargs)
{
    PyObject*self = (PyObject*)PyObject_New(MatrixObject, &MatrixClass);
    MatrixObject*matrix = (MatrixObject*)self;
    mylog("+%08x(%d) f_Matrix", self, self->ob_refcnt);
    static char *kwlist[] = {"x", "y", "scale", "rotate", "pivotx", "pivoty", NULL};
    float x=0,y=0,scale=1.0,rotate=0,pivotx=0,pivoty=0;
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ffffff", kwlist, &x,&y,&scale,&rotate,&pivotx,&pivoty))
	return NULL;
    mylog(" %08x(%d) f_Matrix: x=%f y=%f scale=%f rotate=%f", self, self->ob_refcnt, x,y,scale,rotate);
    swf_GetMatrix(0, &matrix->matrix);

    matrix->matrix.tx = (int)(x*20);
    matrix->matrix.ty = (int)(y*20);

    if(!rotate) {
    	matrix->matrix.sx = (int)(scale*65536);
    	matrix->matrix.sy = (int)(scale*65536);
    } else {
	matrix->matrix.sx = (int)(scale*cos(rotate)*65536);
	matrix->matrix.sy = (int)(scale*cos(rotate)*65536);
	matrix->matrix.r0 = (int)(scale*sin(rotate)*65536);
	matrix->matrix.r1 = (int)(-scale*sin(rotate)*65536);
    }
    if(pivotx || pivoty) {
	SPOINT p,d;
	p.x = (int)(pivotx*20);
	p.y = (int)(pivoty*20);
	p = swf_TurnPoint(p, &matrix->matrix);
	matrix->matrix.tx += matrix->matrix.tx-p.x;
	matrix->matrix.ty += matrix->matrix.ty-p.y;
    }

    /* TODO: rotate */
    return self;
}