GED 2006 (C++)
File detail
Source code
/*
* File: contrastup.cc - Plugin Contrast up
* Project: GED - bitmap editor (ICP)
* Author: Lukas Hefka, xhefka00
* Team: xdudka00, xfilak01, xhefka00, xhradi08
* Created: 2006-04-04
*/
#include <string>
#include <vector>
#include "gedplugin.h"
using std::string;
using std::vector;
/**
* Process one pixel.
* \param pixel Pixel to process.
*/
void processPixel (Pixel &pixel)
{
const float fIntenzity = 0.8;
pixel.red = static_cast<unsigned char>(pixel.red * fIntenzity);
pixel.green = static_cast<unsigned char>(pixel.green * fIntenzity);
pixel.blue = static_cast<unsigned char>(pixel.blue * fIntenzity);
}
/**
* Plugin core function
* \param fb Reference to frambe buffer to work with.
* \return Return error-code, 0 if success.
*/
int core (FrameBuffer &fb, vector<string>) {
// Selected area range
const int xMin= fb.select().at.x;
const int yMin= fb.select().at.y;
const int xMax= xMin + fb.select().size.width;
const int yMax= yMin + fb.select().size.height;
for (int y= yMin; y< yMax; y++)
for (int x= xMin; x< xMax; x++)
processPixel (fb [y][x]);
return 0; // success
}
// plugin main() - read the manual if available
int main (int argc, char *argv[]) {
using namespace GedPlugin;
// Create plugin object
Plugin myPlugin (argc, argv);
// Set object properties
PluginDescription desc;
desc.type = TYPE_FILTER; // Plugin category: filter
desc.name = "Contrast up"; // Plugin name
desc.pCore = core; // Plugin core function (!!)
myPlugin.set (desc);
// Execute plugin (if needed)
return myPlugin.exec();
}