~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: CMP_flip.c 12931 2007-12-17 18:20:48Z theeth $
 
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
#include "../CMP_util.h"
 
31
 
 
32
/* **************** Flip  ******************** */
 
33
static bNodeSocketType cmp_node_flip_in[]= {
 
34
        {       SOCK_RGBA, 1, "Image",              0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
 
35
        {       -1, 0, ""       }
 
36
};
 
37
 
 
38
static bNodeSocketType cmp_node_flip_out[]= {
 
39
        {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
40
        {       -1, 0, ""       }
 
41
};
 
42
 
 
43
static void node_composit_exec_flip(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
44
{
 
45
        if(in[0]->data) {
 
46
                CompBuf *cbuf= in[0]->data;
 
47
                CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1);      /* note, this returns zero'd image */
 
48
                int i, src_pix, src_width, src_height, srcydelt, outydelt, x, y;
 
49
                float *srcfp, *outfp;
 
50
                
 
51
                src_pix= cbuf->type;
 
52
                src_width= cbuf->x;
 
53
                src_height= cbuf->y;
 
54
                srcfp= cbuf->rect;
 
55
                outfp= stackbuf->rect;
 
56
                srcydelt= src_width*src_pix;
 
57
                outydelt= srcydelt;
 
58
                
 
59
                if(node->custom1) {             /*set up output pointer for y flip*/
 
60
                        outfp+= (src_height-1)*outydelt;
 
61
                        outydelt= -outydelt;
 
62
                }
 
63
 
 
64
                for(y=0; y<src_height; y++) {
 
65
                        if(node->custom1 == 1) {        /* no x flip so just copy line*/
 
66
                                memcpy(outfp, srcfp, sizeof(float) * src_pix * src_width);
 
67
                                srcfp+=srcydelt;
 
68
                        }
 
69
                        else {
 
70
                                outfp += (src_width-1)*src_pix;
 
71
                                for(x=0; x<src_width; x++) {
 
72
                                        for(i=0; i<src_pix; i++) {
 
73
                                                outfp[i]= srcfp[i];
 
74
                                        }
 
75
                                        outfp -= src_pix;
 
76
                                        srcfp += src_pix;
 
77
                                }
 
78
                                outfp += src_pix;
 
79
                        }
 
80
                        outfp += outydelt;
 
81
                }
 
82
 
 
83
                out[0]->data= stackbuf;
 
84
 
 
85
        }
 
86
}
 
87
 
 
88
bNodeType cmp_node_flip= {
 
89
        /* *next,*prev */       NULL, NULL,
 
90
        /* type code   */       CMP_NODE_FLIP,
 
91
        /* name        */       "Flip",
 
92
        /* width+range */       140, 100, 320,
 
93
        /* class+opts  */       NODE_CLASS_DISTORT, NODE_OPTIONS,
 
94
        /* input sock  */       cmp_node_flip_in,
 
95
        /* output sock */       cmp_node_flip_out,
 
96
        /* storage     */       "",
 
97
        /* execfunc    */       node_composit_exec_flip,
 
98
        /* butfunc     */       NULL,
 
99
        /* initfunc    */       NULL,
 
100
        /* freestoragefunc    */        NULL,
 
101
        /* copystoragefunc    */        NULL,
 
102
        /* id          */       NULL
 
103
};
 
104
 
 
105