Mercurial > audlegacy-plugins
annotate src/paranormal/general.c @ 328:a4d2caa1da63 trunk
[svn] Well I think it's pretty
author | nazca |
---|---|
date | Mon, 04 Dec 2006 01:07:59 -0800 |
parents | 8f4dc0d63925 |
children | a7c98f237b03 |
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]; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
114 register int sum; |
177 | 115 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
|
116 |
175 | 117 for (j=0; j<pn_image_data->height; j += radius) |
118 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
|
119 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
120 int ii = 0, jj = 0; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
121 guchar bval = 0; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
122 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
123 /* find the brightest colour */ |
175 | 124 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
125 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
|
126 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
127 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
|
128 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
129 if (val > bval) |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
130 bval = val; |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
131 } |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
132 |
175 | 133 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
134 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
|
135 { |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
136 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
|
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 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
140 pn_swap_surfaces (); |
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 |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
143 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
|
144 { |
176 | 145 "general_mosaic", "Mosaic", "A simple mosaic effect.", |
175 | 146 0, general_mosaic_opts, |
174
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
147 NULL, NULL, general_mosaic_exec |
3d98be3d74c2
[svn] - mosaic effect (in progress, custom size will be in the next commit)
nenolod
parents:
155
diff
changeset
|
148 }; |
177 | 149 |
150 /* **************** general_clear **************** */ | |
151 static void | |
152 general_clear_exec (const struct pn_actuator_option *opts, | |
153 gpointer data) | |
154 { | |
155 memset(pn_image_data->surface[0], '\0', | |
156 (pn_image_data->height * pn_image_data->width)); | |
157 } | |
158 | |
159 struct pn_actuator_desc builtin_general_clear = | |
160 { | |
161 "general_clear", "Clear Surface", "Clears the surface.", | |
162 0, NULL, | |
163 NULL, NULL, general_clear_exec | |
164 }; | |
165 | |
179
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
166 /* **************** general_noop **************** */ |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
167 static void |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
168 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
|
169 gpointer data) |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
170 { |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
171 return; |
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 |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
174 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
|
175 { |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
176 "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
|
177 0, NULL, |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
178 NULL, NULL, general_noop_exec |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
179 }; |
b44ab11a64c2
[svn] - NOOP instruction. What this does is basically takes a slot in a
nenolod
parents:
177
diff
changeset
|
180 |
181 | 181 /* **************** general_invert **************** */ |
182 static void | |
183 general_invert_exec (const struct pn_actuator_option *opts, | |
184 gpointer data) | |
185 { | |
186 int i, j; | |
187 | |
188 for (j=0; j < pn_image_data->height; j++) | |
189 for (i=0; i < pn_image_data->width; i++) | |
190 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = | |
191 255 - pn_image_data->surface[0][PN_IMG_INDEX (i, j)]; | |
192 } | |
193 | |
194 struct pn_actuator_desc builtin_general_invert = | |
195 { | |
196 "general_invert", "Value Invert", "Performs a value invert.", | |
197 0, NULL, | |
198 NULL, NULL, general_invert_exec | |
199 }; | |
200 | |
182
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
201 /* **************** general_replace **************** */ |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
202 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
|
203 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
204 { "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
|
205 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
|
206 { "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
|
207 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
|
208 { "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
|
209 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
|
210 { NULL } |
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 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
213 static void |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
214 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
|
215 gpointer data) |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
216 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
217 register int i, j; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
218 register guchar val; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
223 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
|
224 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
|
225 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
226 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
|
227 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
|
228 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
|
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 |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
232 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
|
233 { |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
234 "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
|
235 0, general_replace_opts, |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
236 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
|
237 }; |
6048abdac7d1
[svn] - add value replace filter, replaces a range of values with a different value
nenolod
parents:
181
diff
changeset
|
238 |
271 | 239 /* **************** general_swap **************** */ |
240 static void | |
241 general_swap_exec (const struct pn_actuator_option *opts, | |
242 gpointer data) | |
243 { | |
244 pn_swap_surfaces (); | |
245 } | |
246 | |
247 struct pn_actuator_desc builtin_general_swap = | |
248 { | |
249 "general_swap", "Swap Surface", "Swaps the surface.", | |
250 0, NULL, | |
251 NULL, NULL, general_swap_exec | |
252 }; | |
272 | 253 |
254 /* **************** general_copy **************** */ | |
255 static void | |
256 general_copy_exec (const struct pn_actuator_option *opts, | |
257 gpointer data) | |
258 { | |
259 memcpy(pn_image_data->surface[1], pn_image_data->surface[0], | |
260 (pn_image_data->width * pn_image_data->height)); | |
261 } | |
262 | |
263 struct pn_actuator_desc builtin_general_copy = | |
264 { | |
265 "general_copy", "Copy Surface", "Copies the surface to the other surface.", | |
266 0, NULL, | |
267 NULL, NULL, general_copy_exec | |
268 }; | |
278 | 269 |
270 /* **************** general_flip **************** */ | |
271 static struct pn_actuator_option_desc general_flip_opts[] = | |
272 { | |
273 { "direction", "Negative is horizontal, positive is vertical.", | |
274 OPT_TYPE_INT, { ival: -1 } }, | |
275 { NULL } | |
276 }; | |
277 | |
278 static void | |
279 general_flip_exec (const struct pn_actuator_option *opts, | |
280 gpointer data) | |
281 { | |
282 gint x, y; | |
283 | |
284 if (opts[0].val.ival < 0) | |
285 { | |
286 for (y = 0; y < pn_image_data->height; y++) | |
287 for (x = 0; x < pn_image_data->width; x++) | |
288 { | |
289 pn_image_data->surface[1][PN_IMG_INDEX(pn_image_data->width - x, y)] = | |
290 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; | |
291 } | |
292 } | |
293 else | |
294 { | |
295 for (y = 0; y < pn_image_data->height; y++) | |
296 for (x = 0; x < pn_image_data->width; x++) | |
297 { | |
298 pn_image_data->surface[1][PN_IMG_INDEX(x, pn_image_data->height - y)] = | |
299 pn_image_data->surface[0][PN_IMG_INDEX(x, y)]; | |
300 } | |
301 } | |
302 | |
303 pn_swap_surfaces (); | |
304 } | |
305 | |
306 struct pn_actuator_desc builtin_general_flip = | |
307 { | |
308 "general_flip", "Flip Surface", "Flips the surface.", | |
309 0, general_flip_opts, | |
310 NULL, NULL, general_flip_exec | |
311 }; |