From 4d64e4cd434426234a5c313c151cd79b6afc299e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Vehvil=C3=A4inen?= Date: Sat, 6 Jul 2002 17:50:18 +0000 Subject: *** empty log message *** svn path=/trunk/Framestein/; revision=27 --- Patches/vcolor~.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Patches/vcolor~.c (limited to 'Patches/vcolor~.c') diff --git a/Patches/vcolor~.c b/Patches/vcolor~.c new file mode 100644 index 0000000..0de7fe6 --- /dev/null +++ b/Patches/vcolor~.c @@ -0,0 +1,96 @@ +#include "m_pd.h" +#include "math.h" +#include "sharemem.h" +#include "vframe.h" +#include "plugin.h" +#include "displaydepth.h" + +/* -------------------------- vcolor~ ------------------------------ */ +static t_class *vcolor_class; + +typedef struct _vcolor +{ + t_object x_obj; + float x_r; + float x_g; + float x_b; + int depth; +} t_vcolor; + +static t_int *vcolor_perform(t_int *w) +{ + t_float *in_r = (t_float *)(w[1]); + t_float *in_g = (t_float *)(w[2]); + t_float *in_b = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + int n = (int)(w[5]); + t_vcolor *x = (t_vcolor *)(w[6]); + + switch(x->depth) + { + case 16: + while (n--) + { + *out++ = colortosample16(rgbtocolor16( + (byte)(*in_r++*255.0), + (byte)(*in_g++*255.0), + (byte)(*in_b++*255.0) + )); + } + break; + case 32: + while (n--) + { + *out++ = colortosample32(rgbtocolor32( + (byte)(*in_r++*255.0), + (byte)(*in_g++*255.0), + (byte)(*in_b++*255.0))); + } + break; + } + return (w+7); +} + +static void vcolor_dsp(t_vcolor *x, t_signal **sp) +{ + dsp_add(vcolor_perform, 6, + sp[0]->s_vec, + sp[1]->s_vec, + sp[2]->s_vec, + sp[3]->s_vec, + sp[0]->s_n, + x); +} + +static void vcolor_float(t_vcolor *x, t_float f) +{ +} + +static void *vcolor_new(t_floatarg f) +{ + t_vcolor *x = (t_vcolor *)pd_new(vcolor_class); + x->depth = getdisplaydepth(); + if(!x->depth) + { + post("vcolor~: getdisplaydepth() failed, defaulting to 16."); + x->depth = 16; + } + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + return (x); +} + +static void vcolor_destroy(t_vcolor *x) +{ +} + +void vcolor_tilde_setup(void) +{ + vcolor_class = class_new(gensym("vcolor~"), + (t_newmethod)vcolor_new, (t_method)vcolor_destroy, + sizeof(t_vcolor), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(vcolor_class, t_vcolor, x_r); + class_addfloat(vcolor_class, (t_method)vcolor_float); + class_addmethod(vcolor_class, (t_method)vcolor_dsp, gensym("dsp"), 0); +} -- cgit v1.2.1