All pastes #613962 Raw Edit

Someone

public c v1 · immutable
·published 2007-07-11 08:03 UTC
rendered paste body
static void node_composit_exec_rotate(void *data, bNode *node, bNodeStack **in, bNodeStack **out){		if(out[0]->hasoutput==0)		return;		if(in[0]->data) {		CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);		CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1);	/* note, this returns zero'd image */		float *ofp, rad, u, v, s, c, centx, centy, miny, maxy, minx, maxx;		int x, y, yo;			rad= (M_PI*in[1]->vec[0])/180.0f;				s= sin(rad);		c= cos(rad);		centx= cbuf->x/2;		centy= cbuf->y/2;				minx= -centx;		maxx= -centx + (float)cbuf->x;		miny= -centy;		maxy= -centy + (float)cbuf->y;				for(y=miny; y<maxy; y++) {			yo= y+(int)centy;			ofp= stackbuf->rect + 4*yo*stackbuf->x;						for(x=minx; x<maxx; x++, ofp+=4) {				u= c*x + y*s + centx;				v= -s*x + c*y + centy;								bilinear_interpolation_rotate(cbuf, ofp, u, v);if(node->custom1==0){  bilinear_interpolation((ImBuf *)cbuf, (ImBuf *) stackbuf, u, v, x, y);}else if(node->custom1==1){  neareast_interpolation((ImBuf *)cbuf, (ImBuf *) stackbuf, u, v, x, y);}else{  bicubic_interpolation((ImBuf *)cbuf, (ImBuf *) stackbuf, u, v, x, y);}			}		}		/* rotate offset vector too, but why negative rad, ehh?? Has to be replaced with [3][3] matrix once (ton) */		s= sin(-rad);		c= cos(-rad);		centx= (float)cbuf->xof; centy= (float)cbuf->yof;		stackbuf->xof= (int)( c*centx + s*centy);		stackbuf->yof= (int)(-s*centx + c*centy);				/* pass on output and free */		out[0]->data= stackbuf;		if(cbuf!=in[0]->data)			free_compbuf(cbuf);			}}