Mercurial > audlegacy-plugins
comparison src/paranormal/general.c @ 175:5635841a0686 trunk
[svn] - make mosaic sizable.
author | nenolod |
---|---|
date | Wed, 01 Nov 2006 01:00:19 -0800 |
parents | 3d98be3d74c2 |
children | c93118f6ef27 |
comparison
equal
deleted
inserted
replaced
174:3d98be3d74c2 | 175:5635841a0686 |
---|---|
12 static struct pn_actuator_option_desc general_fade_opts[] = | 12 static struct pn_actuator_option_desc general_fade_opts[] = |
13 { | 13 { |
14 { "amount", "The amount by which the color index of each " | 14 { "amount", "The amount by which the color index of each " |
15 "pixel should be decreased by each frame (MAX 255)", | 15 "pixel should be decreased by each frame (MAX 255)", |
16 OPT_TYPE_INT, { ival: 3 } }, | 16 OPT_TYPE_INT, { ival: 3 } }, |
17 { 0 } | 17 { NULL } |
18 }; | 18 }; |
19 | 19 |
20 static void | 20 static void |
21 general_fade_exec (const struct pn_actuator_option *opts, | 21 general_fade_exec (const struct pn_actuator_option *opts, |
22 gpointer data) | 22 gpointer data) |
96 }; | 96 }; |
97 | 97 |
98 /* **************** general_mosaic **************** */ | 98 /* **************** general_mosaic **************** */ |
99 /* FIXME: add a variable radius */ | 99 /* FIXME: add a variable radius */ |
100 /* FIXME: SPEEEED */ | 100 /* FIXME: SPEEEED */ |
101 static struct pn_actuator_option_desc general_mosaic_opts[] = | |
102 { | |
103 { "radius", "The pixel radius that should be used for the effect.", | |
104 OPT_TYPE_INT, { ival: 6 } }, | |
105 { NULL } | |
106 }; | |
107 | |
101 static void | 108 static void |
102 general_mosaic_exec (const struct pn_actuator_option *opts, | 109 general_mosaic_exec (const struct pn_actuator_option *opts, |
103 gpointer data) | 110 gpointer data) |
104 { | 111 { |
105 int i,j; | 112 int i,j; |
106 register guchar *srcptr = pn_image_data->surface[0]; | 113 register guchar *srcptr = pn_image_data->surface[0]; |
107 register guchar *destptr = pn_image_data->surface[1]; | 114 register guchar *destptr = pn_image_data->surface[1]; |
108 register int sum; | 115 register int sum; |
116 int radius = opts[0].val.ival; | |
109 | 117 |
110 for (j=0; j<pn_image_data->height; j += 6) | 118 for (j=0; j<pn_image_data->height; j += radius) |
111 for (i=0; i<pn_image_data->width; i += 6) | 119 for (i=0; i<pn_image_data->width; i += radius) |
112 { | 120 { |
113 int ii = 0, jj = 0; | 121 int ii = 0, jj = 0; |
114 guchar bval = 0; | 122 guchar bval = 0; |
115 | 123 |
116 /* find the brightest colour */ | 124 /* find the brightest colour */ |
117 for (jj = 0; jj < 6 && (j + jj < pn_image_data->height); jj++) | 125 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
118 for (ii = 0; ii < 6 && (i + ii < pn_image_data->width); ii++) | 126 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++) |
119 { | 127 { |
120 guchar val = srcptr[PN_IMG_INDEX(i + ii, j + jj)]; | 128 guchar val = srcptr[PN_IMG_INDEX(i + ii, j + jj)]; |
121 | 129 |
122 if (val > bval) | 130 if (val > bval) |
123 bval = val; | 131 bval = val; |
124 } | 132 } |
125 | 133 |
126 for (jj = 0; jj < 6 && (j + jj < pn_image_data->height); jj++) | 134 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++) |
127 for (ii = 0; ii < 6 && (i + ii < pn_image_data->width); ii++) | 135 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++) |
128 { | 136 { |
129 destptr[PN_IMG_INDEX(i + ii, j + jj)] = bval; | 137 destptr[PN_IMG_INDEX(i + ii, j + jj)] = bval; |
130 } | 138 } |
131 } | 139 } |
132 | 140 |
134 } | 142 } |
135 | 143 |
136 struct pn_actuator_desc builtin_general_mosaic = | 144 struct pn_actuator_desc builtin_general_mosaic = |
137 { | 145 { |
138 "general_mosaic", "Mosaic", "A simple 6 pixel radius Mosaic", | 146 "general_mosaic", "Mosaic", "A simple 6 pixel radius Mosaic", |
139 0, NULL, | 147 0, general_mosaic_opts, |
140 NULL, NULL, general_mosaic_exec | 148 NULL, NULL, general_mosaic_exec |
141 }; | 149 }; |