|
Blender
V2.59
|
00001 /* 00002 * $Id: CMP_flip.c 35237 2011-02-27 20:13:22Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2006 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #include "../CMP_util.h" 00036 00037 /* **************** Flip ******************** */ 00038 static bNodeSocketType cmp_node_flip_in[]= { 00039 { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, 00040 { -1, 0, "" } 00041 }; 00042 00043 static bNodeSocketType cmp_node_flip_out[]= { 00044 { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00045 { -1, 0, "" } 00046 }; 00047 00048 static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) 00049 { 00050 if(in[0]->data) { 00051 CompBuf *cbuf= in[0]->data; 00052 CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); /* note, this returns zero'd image */ 00053 int i, src_pix, src_width, src_height, srcydelt, outydelt, x, y; 00054 float *srcfp, *outfp; 00055 00056 src_pix= cbuf->type; 00057 src_width= cbuf->x; 00058 src_height= cbuf->y; 00059 srcfp= cbuf->rect; 00060 outfp= stackbuf->rect; 00061 srcydelt= src_width*src_pix; 00062 outydelt= srcydelt; 00063 00064 if(node->custom1) { /*set up output pointer for y flip*/ 00065 outfp+= (src_height-1)*outydelt; 00066 outydelt= -outydelt; 00067 } 00068 00069 for(y=0; y<src_height; y++) { 00070 if(node->custom1 == 1) { /* no x flip so just copy line*/ 00071 memcpy(outfp, srcfp, sizeof(float) * src_pix * src_width); 00072 srcfp+=srcydelt; 00073 } 00074 else { 00075 outfp += (src_width-1)*src_pix; 00076 for(x=0; x<src_width; x++) { 00077 for(i=0; i<src_pix; i++) { 00078 outfp[i]= srcfp[i]; 00079 } 00080 outfp -= src_pix; 00081 srcfp += src_pix; 00082 } 00083 outfp += src_pix; 00084 } 00085 outfp += outydelt; 00086 } 00087 00088 out[0]->data= stackbuf; 00089 00090 } 00091 } 00092 00093 void register_node_type_cmp_flip(ListBase *lb) 00094 { 00095 static bNodeType ntype; 00096 00097 node_type_base(&ntype, CMP_NODE_FLIP, "Flip", NODE_CLASS_DISTORT, NODE_OPTIONS, 00098 cmp_node_flip_in, cmp_node_flip_out); 00099 node_type_size(&ntype, 140, 100, 320); 00100 node_type_exec(&ntype, node_composit_exec_flip); 00101 00102 nodeRegisterType(lb, &ntype); 00103 } 00104 00105 00106