Subversion Repositories filter_foundry

Rev

Rev 79 | Rev 117 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 79 Rev 106
Line 1... Line 1...
1
/*
1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-5 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-5 Toby Thain, toby@telegraphics.com.au
4
 
4
 
5
    This program is free software; you can redistribute it and/or modify
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by  
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
8
    (at your option) any later version.
9
 
9
 
10
    This program is distributed in the hope that it will be useful,
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
13
    GNU General Public License for more details.
14
 
14
 
15
    You should have received a copy of the GNU General Public License  
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
*/
18
*/
19
 
19
 
20
#ifdef MAC_ENV
20
#ifdef MAC_ENV
Line 43... Line 43...
43
extern unsigned char *image_ptr;
43
extern unsigned char *image_ptr;
44
 
44
 
45
/* Channel z for the input pixel at coordinates x,y.
45
/* Channel z for the input pixel at coordinates x,y.
46
 * Coordinates are relative to the input image data (pb->inData) */
46
 * Coordinates are relative to the input image data (pb->inData) */
47
static value_type rawsrc(value_type x,value_type y,value_type z){
47
static value_type rawsrc(value_type x,value_type y,value_type z){
48
        if(x < gpb->inRect.left)
48
        if(x < gpb->inRect.left)
49
                x = gpb->inRect.left;
49
                x = gpb->inRect.left;
50
        else if(x >= gpb->inRect.right)
50
        else if(x >= gpb->inRect.right)
51
                x = gpb->inRect.right-1;
51
                x = gpb->inRect.right-1;
52
        if(y < gpb->inRect.top)
52
        if(y < gpb->inRect.top)
53
                y = gpb->inRect.top;
53
                y = gpb->inRect.top;
54
        else if(y >= gpb->inRect.bottom)
54
        else if(y >= gpb->inRect.bottom)
55
                y = gpb->inRect.bottom-1;
55
                y = gpb->inRect.bottom-1;
56
        return ((unsigned char*)gpb->inData)[ (long)gpb->inRowBytes*(y - gpb->inRect.top)
56
        return ((unsigned char*)gpb->inData)[ (long)gpb->inRowBytes*(y - gpb->inRect.top)
57
                                                                                  + (long)nplanes*(x - gpb->inRect.left) + z ];
57
                                                                                  + (long)nplanes*(x - gpb->inRect.left) + z ];
58
}
58
}
59
 
59
 
Line 61... Line 61...
61
 * Coordinates are relative to filtered area (selection). */
61
 * Coordinates are relative to filtered area (selection). */
62
value_type ff_src(value_type x,value_type y,value_type z){
62
value_type ff_src(value_type x,value_type y,value_type z){
63
#ifdef PARSERTEST
63
#ifdef PARSERTEST
64
        return 0;
64
        return 0;
65
#else
65
#else
66
        if(x < 0)
66
        if(x < 0)
67
                x = 0;
67
                x = 0;
68
        else if(x >= var['X'])
68
        else if(x >= var['X'])
69
                x = var['X']-1;
69
                x = var['X']-1;
70
        if(y < 0)
70
        if(y < 0)
71
                y = 0;
71
                y = 0;
72
        else if(y >= var['Y'])
72
        else if(y >= var['Y'])
73
                y = var['Y']-1;
73
                y = var['Y']-1;
74
        return z >= 0 && z < var['Z'] ?
74
        return z >= 0 && z < var['Z'] ?
75
                image_ptr[(long)gpb->inRowBytes*y + (long)nplanes*x + z] : 0;
75
                image_ptr[(long)gpb->inRowBytes*y + (long)nplanes*x + z] : 0;
76
#endif
76
#endif
77
}
77
}
Line 272... Line 272...
272
 
272
 
273
        return d ? total/d : 0;
273
        return d ? total/d : 0;
274
#endif
274
#endif
275
}
275
}
276
 
276
 
-
 
277
/* rst(i) sets a random seed and returns 0. (undocumented Filter Factory function).
-
 
278
   Added by DM, 18 Dec 2018 */
-
 
279
value_type ff_rst(value_type seed){
-
 
280
        srand(seed);
-
 
281
        return 0;
-
 
282
}
-
 
283
 
277
value_type zero_val = 0;
284
value_type zero_val = 0;
278
 
285
 
279
/* predefined symbols */
286
/* predefined symbols */
280
struct sym_rec predefs[]={
287
struct sym_rec predefs[]={
281
        /* functions */
288
        /* functions */
Line 302... Line 309...
302
        {0,TOK_FN2,"c2d", (pfunc_type)ff_c2d, 0},
309
        {0,TOK_FN2,"c2d", (pfunc_type)ff_c2d, 0},
303
        {0,TOK_FN2,"c2m", (pfunc_type)ff_c2m, 0},
310
        {0,TOK_FN2,"c2m", (pfunc_type)ff_c2m, 0},
304
        {0,TOK_FN1,"get", (pfunc_type)ff_get, 0},
311
        {0,TOK_FN1,"get", (pfunc_type)ff_get, 0},
305
        {0,TOK_FN2,"put", (pfunc_type)ff_put, 0},
312
        {0,TOK_FN2,"put", (pfunc_type)ff_put, 0},
306
        {0,TOK_FN10,"cnv",(pfunc_type)ff_cnv, 0},
313
        {0,TOK_FN10,"cnv",(pfunc_type)ff_cnv, 0},
-
 
314
        {0,TOK_FN1,"rst", (pfunc_type)ff_rst, 0},
307
        /* predefined variables (names >1 characters) */
315
        /* predefined variables (names >1 characters) */
308
        {0,TOK_VAR,"dmin",0, &zero_val},
316
        {0,TOK_VAR,"dmin",0, &zero_val},
309
        {0,TOK_VAR,"mmin",0, &zero_val},
317
        {0,TOK_VAR,"mmin",0, &zero_val},
310
        {0,0,0,0,0}
318
        {0,0,0,0,0}
311
};
319
};