GED 2006 (C++)
File detail
Source code
/*
* File: contrastdown.cc - Plugin Contrast down
* 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;
/**
* Return minumum from a and b.
*/
unsigned min (unsigned a, unsigned b) {
return (a<b) ? a:b;
}
/**
* Process one pixel.
* \param pixel Pixel to process.
*/
void processPixel (Pixel &pixel)
{
const float fIntenzity = 1.2;
unsigned uColor;
// for red color
uColor = static_cast<unsigned> (pixel.red * fIntenzity);
pixel.red = min (uColor, UCHAR_MAX);
// for green color
uColor = static_cast<unsigned> (pixel.green * fIntenzity);
pixel.green = min (uColor, UCHAR_MAX);
// for blue color
uColor = static_cast<unsigned> (pixel.blue * fIntenzity);
pixel.blue = min (uColor, UCHAR_MAX);
}
/**
* 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 down"; // Plugin name
desc.pCore = core; // Plugin core function (!!)
myPlugin.set (desc);
// Execute plugin (if needed)
return myPlugin.exec();
}