/* A simple plug-in that returns the image that is an average of two input images */ #include "EF.h" #include #include void averageImages(EF_Image *image1, EF_Image *image2, EF_Image *result, float); /* This is called when the plug-in is loaded by the video editor. We register the plug-in with the editor by filling in the options structure */ void pluginInit(EF_PluginOptions *options) { if (options->structSize!=sizeof(EF_PluginOptions)) { puts("Plugin is wrong version"); return; } /* Set the pluginComposite field in options to point to our averageImages() function. Also set name to be the name of this plugin. */ options->pluginComposite = averageImages; strcpy(options->name,"Average"); } void averageImages(EF_Image *image1, EF_Image *image2, EF_Image *result, float) { /* Loop over all of the pixels in each image */ for (int x = 0; x < image1->xSize; x++) for(int y = 0; y < image1->ySize; y++) { /* Get the pixel from each image */ long pix1 = EF_ImageXY(image1, x, y); long pix2 = EF_ImageXY(image2, x, y); long pixAvg; /* Compute the average of each component */ RED(pixAvg) = (RED(pix1) + RED(pix2)) / 2; GREEN(pixAvg) = (GREEN(pix1) + GREEN(pix2)) / 2; BLUE(pixAvg) = (BLUE(pix1) + BLUE(pix2)) / 2; ALPHA(pixAvg) = (ALPHA(pix1) + ALPHA(pix2)) / 2; /* Set the corresponding pixel in the result image with the average pixel */ EF_ImageXY(result, x, y)= pixAvg; } }