~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/CMP_nodes/CMP_gamma.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* $Id: CMP_gamma.c,v 1.1 2007/04/13 04:22:32 scourage Exp $
 
3
*
 
4
* ***** BEGIN GPL LICENSE BLOCK *****
 
5
*
 
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. 
 
10
*
 
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.
 
15
 
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.
 
19
 
20
* The Original Code is Copyright (C) 2006 Blender Foundation.
 
21
* All rights reserved.
 
22
 
23
* The Original Code is: all of this file.
 
24
 
25
* Contributor(s): none yet.
 
26
 
27
* ***** END GPL LICENSE BLOCK *****
 
28
 
 
29
*/
 
30
 
 
31
#include "../CMP_util.h"
 
32
 
 
33
/* **************** Gamma Tools  ******************** */
 
34
  
 
35
static bNodeSocketType cmp_node_gamma_in[]= {
 
36
        {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
 
37
        {       SOCK_VALUE, 1, "Gamma",                 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 2.0f},
 
38
    {   -1, 0, ""       }
 
39
};
 
40
static bNodeSocketType cmp_node_gamma_out[]= {
 
41
        {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
42
        {       -1, 0, ""       }
 
43
};
 
44
 
 
45
static void do_gamma(bNode *node, float *out, float *in, float *fac)
 
46
{
 
47
        int i=0;
 
48
        for(i=0; i<3; i++) {
 
49
                out[i] = pow(in[i],fac[0]);
 
50
        }
 
51
        out[3] = in[3];
 
52
}
 
53
static void node_composit_exec_gamma(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
54
{
 
55
        /* stack order in: Fac, Image */
 
56
        /* stack order out: Image */
 
57
        if(out[0]->hasoutput==0) return;
 
58
        
 
59
        /* input no image? then only color operation */
 
60
        if(in[0]->data==NULL) {
 
61
                do_gamma(node, out[0]->vec, in[0]->vec, in[1]->vec);
 
62
        }
 
63
        else {
 
64
                /* make output size of input image */
 
65
                CompBuf *cbuf= in[0]->data;
 
66
                CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
 
67
                
 
68
                composit2_pixel_processor(node, stackbuf, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_gamma, CB_RGBA, CB_VAL);
 
69
 
 
70
                out[0]->data= stackbuf;
 
71
        }
 
72
}
 
73
 
 
74
bNodeType cmp_node_gamma= {
 
75
        /* *next,*prev */       NULL, NULL,
 
76
        /* type code   */       CMP_NODE_GAMMA,
 
77
        /* name        */       "Gamma",
 
78
        /* width+range */       140, 100, 320,
 
79
        /* class+opts  */       NODE_CLASS_OP_COLOR, NODE_OPTIONS,
 
80
        /* input sock  */       cmp_node_gamma_in,
 
81
        /* output sock */       cmp_node_gamma_out,
 
82
        /* storage     */       "",
 
83
        /* execfunc    */       node_composit_exec_gamma,       
 
84
        /* butfunc     */       NULL,
 
85
        /* initfunc    */       NULL,
 
86
        /* freestoragefunc      */ NULL,
 
87
        /* copysotragefunc      */ NULL,
 
88
        /* id          */       NULL
 
89
};
 
90
 
 
91