diff options
author | N.N. <sevyves@users.sourceforge.net> | 2010-08-15 17:19:04 +0000 |
---|---|---|
committer | N.N. <sevyves@users.sourceforge.net> | 2010-08-15 17:19:04 +0000 |
commit | 64e5eee3e7bcbb2c8469d8daafd18a166a1968f0 (patch) | |
tree | 401bb97735d1756885c8f2da686636bce34b22ec /modules | |
parent | 70276678d4cadf6249c9b3e0cbcfa6b55086d358 (diff) |
invert red and blue channels
svn path=/trunk/externals/pidip/; revision=13799
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/pdp_vloopback.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/pdp_vloopback.c b/modules/pdp_vloopback.c index 12f9e31..c475d6f 100755 --- a/modules/pdp_vloopback.c +++ b/modules/pdp_vloopback.c @@ -59,6 +59,7 @@ typedef struct pdp_vloopback_struct t_outlet *x_outlet1; int x_nbframes; + int x_invertrb; struct video_window x_vidwin; struct video_picture x_vidpic; @@ -201,6 +202,8 @@ static void pdp_vloopback_process_rgb(t_pdp_vloopback *x) { t_pdp *header = pdp_packet_header(x->x_packet0); char *data = (char *)pdp_packet_data(x->x_packet0); + char cvalue; + unsigned int px,py; int written, flength; if ( !x->x_initialized ) @@ -218,6 +221,20 @@ static void pdp_vloopback_process_rgb(t_pdp_vloopback *x) // output the image flength = x->x_width*x->x_height*3; + // invert red and blue channels ( with webcamstudio module ) + if ( x->x_invertrb ) + { + for ( py=0; py<x->x_height; py++ ) + { + for ( px=0; px<x->x_width; px++ ) + { + cvalue=*(data+3*py*x->x_width+3*px); + *(data+3*py*x->x_width+3*px)=*(data+3*py*x->x_width+3*px+2); + *(data+3*py*x->x_width+3*px+2)=cvalue; + } + } + } + if ( ( written = write(x->x_vlfd, data, flength) ) != flength ) { post( "pdp_vloopback : problem writing frame...closing" ); @@ -278,6 +295,14 @@ static void pdp_vloopback_input_0(t_pdp_vloopback *x, t_symbol *s, t_floatarg f) } } +static void pdp_vloopback_invertrb(t_pdp_vloopback *x, t_floatarg finvert) +{ + if ( ((int)finvert == 0) || ((int)finvert == 1) ) + { + x->x_invertrb = (int)finvert; + } +} + static void pdp_vloopback_free(t_pdp_vloopback *x) { pdp_vloopback_close(x); @@ -294,6 +319,7 @@ void *pdp_vloopback_new(t_symbol *vdev) x->x_initialized = false; x->x_nbframes = 0; + x->x_invertrb = 1; x->x_packet0 = -1; x->x_packet1 = -1; @@ -330,6 +356,7 @@ void pdp_vloopback_setup(void) class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_close, gensym("close"), A_NULL); class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_open, gensym("open"), A_SYMBOL, A_NULL); class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL); + class_addmethod(pdp_vloopback_class, (t_method)pdp_vloopback_invertrb, gensym("invert"), A_DEFFLOAT, A_NULL); } |