Mercurial > audlegacy-plugins
annotate src/rovascope/general.c @ 1263:458d46e65a86
wav-sndfile: in is_our_file, ensure that filename is not NULL before passing it to sf_open
author | Giacomo Lozito <james@develia.org> |
---|---|
date | Fri, 13 Jul 2007 20:55:42 +0200 |
parents | f305ebcc8136 |
children |
rev | line source |
---|---|
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
1 /* FIXME: what to name this file? */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
2 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
3 #ifdef HAVE_CONFIG_H |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
4 # include <config.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
5 #endif |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
6 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
7 #include "paranormal.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
8 #include "actuators.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
9 #include "pn_utils.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
10 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
11 /* **************** general_fade **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
12 static struct pn_actuator_option_desc general_fade_opts[] = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
13 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
14 { "amount", "The amount by which the color index of each " |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
15 "pixel should be decreased by each frame (MAX 255)", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
16 OPT_TYPE_INT, { ival: 3 } }, |
175 | 17 { NULL } |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
18 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
19 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
20 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
21 general_fade_exec (const struct pn_actuator_option *opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
22 gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
23 { |
177 | 24 int amt = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 3 : opts[0].val.ival; |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
25 int i, j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
26 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
27 for (j=0; j<pn_image_data->height; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
28 for (i=0; i<pn_image_data->width; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
29 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
30 CAPLO (pn_image_data->surface[0][PN_IMG_INDEX (i, j)] |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
31 - amt, 0); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
32 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
33 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
34 struct pn_actuator_desc builtin_general_fade = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
35 { |
155
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
36 "general_fade", "Fade-out", "Decreases the color index of each pixel", |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
37 0, general_fade_opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
38 NULL, NULL, general_fade_exec |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
39 }; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
40 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
41 /* **************** general_blur **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
42 /* FIXME: add a variable radius */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
43 /* FIXME: SPEEEED */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
44 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
45 general_blur_exec (const struct pn_actuator_option *opts, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
46 gpointer data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
47 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
48 int i,j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
49 register guchar *srcptr = pn_image_data->surface[0]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
50 register guchar *destptr = pn_image_data->surface[1]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
51 register int sum; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
52 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
53 for (j=0; j<pn_image_data->height; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
54 for (i=0; i<pn_image_data->width; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
55 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
56 sum = *(srcptr)<<2; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
57 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
58 /* top */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
59 if (j > 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
60 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
61 sum += *(srcptr-pn_image_data->width)<<1; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
62 if (i > 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
63 sum += *(srcptr-pn_image_data->width-1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
64 if (i < pn_image_data->width-1) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
65 sum += *(srcptr-pn_image_data->width+1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
66 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
67 /* bottom */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
68 if (j < pn_image_data->height-1) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
69 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
70 sum += *(srcptr+pn_image_data->width)<<1; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
71 if (i > 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
72 sum += *(srcptr+pn_image_data->width-1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
73 if (i < pn_image_data->width-1) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
74 sum += *(srcptr+pn_image_data->width+1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
75 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
76 /* left */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
77 if (i > 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
78 sum += *(srcptr-1)<<1; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
79 /* right */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
80 if (i < pn_image_data->width-1) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
81 sum += *(srcptr+1)<<1; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
82 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
83 *destptr++ = (guchar)(sum >> 4); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
84 srcptr++; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
85 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
86 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
87 pn_swap_surfaces (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
88 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
89 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
90 struct pn_actuator_desc builtin_general_blur = |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
91 { |
155
adf9f4b26039
[svn] - user-friendly names (UI side unimplemented still)
nenolod
parents:
149
diff
changeset
|
92 "general_blur", "Blur", "A simple 1 pixel radius blur", |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
93 0, NULL, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
94 NULL, NULL, general_blur_exec |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
95 }; |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
96 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
97 /* **************** general_mosaic **************** */ |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
98 /* FIXME: add a variable radius */ |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
99 /* FIXME: SPEEEED */ |
175 | 100 static struct pn_actuator_option_desc general_mosaic_opts[] = |
101 { | |
102 { "radius", "The pixel radius that should be used for the effect.", | |
103 OPT_TYPE_INT, { ival: 6 } }, | |
104 { NULL } | |
105 }; | |
106 | |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
107 static void |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
108 general_mosaic_exec (const struct pn_actuator_option *opts, |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
109 gpointer data) |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
110 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
111 int i,j; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
112 register guchar *srcptr = pn_image_data->surface[0]; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
113 register guchar *destptr = pn_image_data->surface[1]; |
177 | 114 int radius = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 6 : opts[0].val.ival; |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
115 |
175 | 116 for (j=0; j<pn_image_data->height; j += radius) |
117 for (i=0; i<pn_image_data->width; i += radius) | |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
118 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
119 int ii = 0, jj = 0; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
120 guchar bval = 0; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
121 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
122 /* find the brightest colour */ |
175 | 123 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
124 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++) | |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
125 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
126 guchar val = srcptr[PN_IMG_INDEX(i + ii, j + jj)]; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
127 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
128 if (val > bval) |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
129 bval = val; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
130 } |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
131 |
175 | 132 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
133 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++) | |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
134 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
135 destptr[PN_IMG_INDEX(i + ii, j + jj)] = bval; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
136 } |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
137 } |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
138 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
139 pn_swap_surfaces (); |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
140 } |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
141 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
142 struct pn_actuator_desc builtin_general_mosaic = |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
143 { |
176 | 144 "general_mosaic", "Mosaic", "A simple mosaic effect.", |
175 | 145 0, general_mosaic_opts, |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
146 NULL, NULL, general_mosaic_exec |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
147 }; |
177 | 148 |
149 /* **************** general_clear **************** */ | |
150 static void | |
151 general_clear_exec (const struct pn_actuator_option *opts, | |
152 gpointer data) | |
153 { | |
154 memset(pn_image_data->surface[0], '\0', | |
155 (pn_image_data->height * pn_image_data->width)); | |
156 } | |
157 | |
158 struct pn_actuator_desc builtin_general_clear = | |
159 { | |
160 "general_clear", "Clear Surface", "Clears the surface.", | |
161 0, NULL, | |
162 NULL, NULL, general_clear_exec | |
163 }; | |
164 | |
179
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
165 /* **************** general_noop **************** */ |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
166 static void |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
167 general_noop_exec (const struct pn_actuator_option *opts, |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
168 gpointer data) |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
169 { |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
170 return; |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
171 } |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
172 |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
173 struct pn_actuator_desc builtin_general_noop = |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
174 { |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
175 "general_noop", "Do Nothing", "Does absolutely nothing.", |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
176 0, NULL, |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
177 NULL, NULL, general_noop_exec |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
178 }; |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
179 |
181 | 180 /* **************** general_invert **************** */ |
181 static void | |
182 general_invert_exec (const struct pn_actuator_option *opts, | |
183 gpointer data) | |
184 { | |
185 int i, j; | |
186 | |
187 for (j=0; j < pn_image_data->height; j++) | |
188 for (i=0; i < pn_image_data->width; i++) | |
189 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = | |
190 255 - pn_image_data->surface[0][PN_IMG_INDEX (i, j)]; | |
191 } | |
192 | |
193 struct pn_actuator_desc builtin_general_invert = | |
194 { | |
195 "general_invert", "Value Invert", "Performs a value invert.", | |
196 0, NULL, | |
197 NULL, NULL, general_invert_exec | |
198 }; | |
199 | |
182
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
200 /* **************** general_replace **************** */ |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
201 static struct pn_actuator_option_desc general_replace_opts[] = |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
202 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
203 { "start", "The beginning colour value that should be replaced by the value of out.", |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
204 OPT_TYPE_INT, { ival: 250 } }, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
205 { "end", "The ending colour value that should be replaced by the value of out.", |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
206 OPT_TYPE_INT, { ival: 255 } }, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
207 { "out", "The colour value that in is replaced with.", |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
208 OPT_TYPE_INT, { ival: 0 } }, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
209 { NULL } |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
210 }; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
211 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
212 static void |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
213 general_replace_exec (const struct pn_actuator_option *opts, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
214 gpointer data) |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
215 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
216 register int i, j; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
217 register guchar val; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
218 guchar begin = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 250 : opts[0].val.ival; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
219 guchar end = opts[1].val.ival > 255 || opts[1].val.ival < 0 ? 255 : opts[1].val.ival; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
220 guchar out = opts[2].val.ival > 255 || opts[2].val.ival < 0 ? 0 : opts[2].val.ival; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
221 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
222 for (j=0; j < pn_image_data->height; j++) |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
223 for (i=0; i < pn_image_data->width; i++) |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
224 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
225 val = pn_image_data->surface[0][PN_IMG_INDEX (i, j)]; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
226 if (val >= begin && val <= end) |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
227 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = out; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
228 } |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
229 } |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
230 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
231 struct pn_actuator_desc builtin_general_replace = |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
232 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
233 "general_replace", "Value Replace", "Performs a value replace on a range of values.", |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
234 0, general_replace_opts, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
235 NULL, NULL, general_replace_exec |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
236 }; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
237 |
271 | 238 /* **************** general_swap **************** */ |
239 static void | |
240 general_swap_exec (const struct pn_actuator_option *opts, | |
241 gpointer data) | |
242 { | |
243 pn_swap_surfaces (); | |
244 } | |
245 | |
246 struct pn_actuator_desc builtin_general_swap = | |
247 { | |
248 "general_swap", "Swap Surface", "Swaps the surface.", | |
249 0, NULL, | |
250 NULL, NULL, general_swap_exec | |
251 }; | |
272 | 252 |
253 /* **************** general_copy **************** */ | |
254 static void | |
255 general_copy_exec (const struct pn_actuator_option *opts, | |
256 gpointer data) | |
257 { | |
258 memcpy(pn_image_data->surface[1], pn_image_data->surface[0], | |
259 (pn_image_data->width * pn_image_data->height)); | |
260 } | |
261 | |
262 struct pn_actuator_desc builtin_general_copy = | |
263 { | |
264 "general_copy", "Copy Surface", "Copies the surface to the other surface.", | |
265 0, NULL, | |
266 NULL, NULL, general_copy_exec | |
267 }; | |
278 | 268 |
269 /* **************** general_flip **************** */ | |
270 static struct pn_actuator_option_desc general_flip_opts[] = | |
271 { | |
272 { "direction", "Negative is horizontal, positive is vertical.", | |
273 OPT_TYPE_INT, { ival: -1 } }, | |
274 { NULL } | |
275 }; | |
276 | |
277 static void | |
278 general_flip_exec (const struct pn_actuator_option *opts, | |
279 gpointer data) | |
280 { | |
281 gint x, y; | |
282 | |
283 if (opts[0].val.ival < 0) | |
284 { | |
285 for (y = 0; y < pn_image_data->height; y++) | |
286 for (x = 0; x < pn_image_data->width; x++) | |
287 { | |
288 pn_image_data->surface[1][PN_IMG_INDEX(pn_image_data->width - x, y)] = | |
289 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; | |
290 } | |
291 } | |
292 else | |
293 { | |
294 for (y = 0; y < pn_image_data->height; y++) | |
295 for (x = 0; x < pn_image_data->width; x++) | |
296 { | |
297 pn_image_data->surface[1][PN_IMG_INDEX(x, pn_image_data->height - y)] = | |
298 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; | |
299 } | |
300 } | |
301 | |
302 pn_swap_surfaces (); | |
303 } | |
304 | |
305 struct pn_actuator_desc builtin_general_flip = | |
306 { | |
307 "general_flip", "Flip Surface", "Flips the surface.", | |
308 0, general_flip_opts, | |
309 NULL, NULL, general_flip_exec | |
310 }; |