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 *****
29
/** \file blender/nodes/composite/nodes/node_composite_brightness.c
34
#include "node_composite_util.h"
37
/* **************** Brigh and contrsast ******************** */
39
static bNodeSocketTemplate cmp_node_brightcontrast_in[]= {
40
{ SOCK_RGBA, 1, "Image", 1.0f, 1.0f, 1.0f, 1.0f},
41
{ SOCK_FLOAT, 1, "Bright", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
42
{ SOCK_FLOAT, 1, "Contrast", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
45
static bNodeSocketTemplate cmp_node_brightcontrast_out[]= {
46
{ SOCK_RGBA, 0, "Image"},
50
static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, float *in_brightness, float *in_contrast)
55
float brightness = (*in_brightness) / 100.0f;
56
float contrast = *in_contrast;
57
float delta = contrast / 200.0f;
58
a = 1.0f - delta * 2.0f;
60
* The algorithm is by Werner D. Streidt
61
* (http://visca.com/ffactory/archives/5-99/msg00021.html)
62
* Extracted of OpenCV demhist.c
66
b = a * (brightness - delta);
70
b = a * (brightness + delta);
80
static void node_composit_exec_brightcontrast(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
82
if (out[0]->hasoutput==0)
86
CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
87
stackbuf= dupalloc_compbuf(cbuf);
88
composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, do_brightnesscontrast, CB_RGBA, CB_VAL, CB_VAL);
89
out[0]->data = stackbuf;
90
if (cbuf != in[0]->data)
95
void register_node_type_cmp_brightcontrast(bNodeTreeType *ttype)
97
static bNodeType ntype;
99
node_type_base(ttype, &ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
100
node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out);
101
node_type_size(&ntype, 140, 100, 320);
102
node_type_exec(&ntype, node_composit_exec_brightcontrast);
104
nodeRegisterType(ttype, &ntype);