2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2006 Blender Foundation.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
28
/** \file blender/nodes/composite/nodes/node_composite_setalpha.c
33
#include "node_composite_util.h"
35
/* **************** SET ALPHA ******************** */
36
static bNodeSocketTemplate cmp_node_setalpha_in[]= {
37
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f},
38
{ SOCK_FLOAT, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
41
static bNodeSocketTemplate cmp_node_setalpha_out[]= {
42
{ SOCK_RGBA, 0, "Image"},
46
static void node_composit_exec_setalpha(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
48
/* stack order out: RGBA image */
49
/* stack order in: col, alpha */
51
/* input no image? then only color operation */
52
if (in[0]->data==NULL && in[1]->data==NULL) {
53
out[0]->vec[0] = in[0]->vec[0];
54
out[0]->vec[1] = in[0]->vec[1];
55
out[0]->vec[2] = in[0]->vec[2];
56
out[0]->vec[3] = in[1]->vec[0];
59
/* make output size of input image */
60
CompBuf *cbuf= in[0]->data?in[0]->data:in[1]->data;
61
CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
63
if (in[1]->data==NULL && in[1]->vec[0]==1.0f) {
65
composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_copy_rgb, CB_RGBA);
68
/* send an compbuf or a value to set as alpha - composit2_pixel_processor handles choosing the right one */
69
composit2_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL);
72
out[0]->data= stackbuf;
76
void register_node_type_cmp_setalpha(bNodeTreeType *ttype)
78
static bNodeType ntype;
80
node_type_base(ttype, &ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTOR, NODE_OPTIONS);
81
node_type_socket_templates(&ntype, cmp_node_setalpha_in, cmp_node_setalpha_out);
82
node_type_size(&ntype, 120, 40, 140);
83
node_type_exec(&ntype, node_composit_exec_setalpha);
85
nodeRegisterType(ttype, &ntype);