2
* $Id: CMP_idMask.c,v 1.4 2007/04/04 13:58:10 jesterking Exp $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2006 Blender Foundation.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): none yet.
27
* ***** END GPL LICENSE BLOCK *****
30
#include "../CMP_util.h"
33
/* **************** ID Mask ******************** */
35
static bNodeSocketType cmp_node_idmask_in[]= {
36
{ SOCK_VALUE, 1, "ID value", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
39
static bNodeSocketType cmp_node_idmask_out[]= {
40
{ SOCK_VALUE, 0, "Alpha", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
44
/* stackbuf should be zeroed */
45
static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr)
49
char *abuf= MEM_mapallocN(cbuf->x*cbuf->y, "anti ali buf");
52
for(x= cbuf->x*cbuf->y - 1; x>=0; x--)
56
antialias_tagbuf(cbuf->x, cbuf->y, abuf);
59
for(x= cbuf->x*cbuf->y - 1; x>=0; x--)
61
rect[x]= (1.0f/255.0f)*(float)abuf[x];
66
static void node_composit_exec_idmask(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
68
if(out[0]->hasoutput==0)
72
CompBuf *cbuf= in[0]->data;
75
if(cbuf->type!=CB_VAL)
78
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */;
80
do_idmask(stackbuf, cbuf, (float)node->custom1);
82
out[0]->data= stackbuf;
87
bNodeType cmp_node_idmask= {
88
/* *next,*prev */ NULL, NULL,
89
/* type code */ CMP_NODE_ID_MASK,
91
/* width+range */ 140, 100, 320,
92
/* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
93
/* input sock */ cmp_node_idmask_in,
94
/* output sock */ cmp_node_idmask_out,
96
/* execfunc */ node_composit_exec_idmask,
99
/* freestoragefunc */ NULL,
100
/* copystoragefunc */ NULL,