/* Simple plugin that inverts the colors of an image */ #include "EF.h" /* This is called when the plugin is applied to an image. The resulting image should go into outputImage. We ignore v, the time-varying value set in the video editor */ void invert(EF_Image *originalImage, EF_Image *outputImage, float v) { int x, y; /* For each pixel... */ for (x = 0; x < originalImage->xSize; ++x) for (y = 0; y < originalImage->ySize; ++y) { /* Get the pixel and extract r, g, b, and a */ long pixel = EF_ImageXY(originalImage, x, y); int red = RED(pixel); int green = GREEN(pixel); int blue = BLUE(pixel); int alpha = ALPHA(pixel); /* invert r, g, and b. Leave alpha alone */ red = 255 - red; green = 255 - green; blue = 255 - blue; /* Pack the results back in the pixel */ RED(pixel) = red; GREEN(pixel) = green; BLUE(pixel) = blue; /* Set the appropriate pixel of the output image */ EF_ImageXY(outputImage, x, y) = pixel; } } /* Initialization code that is called when the plugin is loaded */ void pluginInit(EF_PluginOptions *options) { if (options->structSize!=sizeof(EF_PluginOptions)) { puts("Plugin is wrong version"); return; } options->pluginApply = invert; strcpy(options->name,"Invert"); options->hotkey='i'; }