/* Description: This plugin inverts colors. It works on one strip as input. Author: Andrew McCargar (andrew@outsideworld.org) Website: http://www.outsideworld.org/projects/blender/plugins.html Licensing: Public Domain Last Modified: Thus Dec 24 23:41:35 EST 2009 */ #include "plugin.h" char name[24]= "Invert"; /* structure for buttons, * butcode name default min max 0 */ VarStruct varstr[]= { LABEL, "Invert color:", 0.0, 0.0, 0.0, "", TOG|INT, "Red ", 1.0, 0.0, 1.0, "Invert red channel", TOG|INT, "Green ", 1.0, 0.0, 1.0, "Invert green channel", TOG|INT, "Blue ", 1.0, 0.0, 1.0, "Invert blue channel", }; /* The cast struct is for input in the main doit function Varstr and Cast must have the same variables in the same order */ typedef struct Cast { int dummy; /* because of the 'label' button */ int red; int green; int blue; } Cast; /* cfra: the current frame */ float cfra; void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); int plugin_seq_getversion(void) { return B_PLUGIN_VERSION; } void plugin_but_changed(int but) { } void plugin_init() { } void invert(char *row, int width, int red, int green, int blue) { /* gets a single line from the buffer */ int x; for (x=0;x < width;x++) { if (red == 1) { *row++ = 255 - *row; } else { *row++ = *row; } if (green == 1) { *row++ = 255 - *row; } else { *row++ = *row; } if (blue == 1) { *row++ = 255 - *row; } else { *row++ = *row; } *row++ = *row; } } void plugin_getinfo(PluginInfo *info) { info->name= name; info->nvars= sizeof(varstr)/sizeof(VarStruct); info->cfra= &cfra; info->varstr= varstr; info->init= plugin_init; info->seq_doit= (SeqDoit) plugin_seq_doit; info->callback= plugin_but_changed; } void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width, int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) { char *in1= (char *)ibuf1->rect; char *out= (char *)outbuf->rect; char *cur_row; int y, x; int length = (width * 4); cur_row = (char *) malloc (length); char *p = cur_row; for (y=0;yred, cast->green, cast->blue); for (x=0;x