Files
MagicSetEditor2/src/gfx/image_effects.cpp
T
twanvl a2e709d86b It is 2007 by now
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@275 0fc631ac-6414-0410-93d0-97cfa31319b6
2007-04-21 17:06:29 +00:00

32 lines
1.2 KiB
C++

//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gfx/gfx.hpp>
#include <util/error.hpp>
// ----------------------------------------------------------------------------- : Saturation
void saturate(Image& image, int amount) {
if (amount == 0) return; // nothing to do
int factor = 300 / amount;
int div = factor - 2;
// for each pixel...
Byte* pix = image.GetData();
Byte* end = pix + image.GetWidth() * image.GetHeight() * 3;
while (pix != end) {
int r = pix[0], g = pix[1], b = pix[2];
int r2 = (factor * r - g - b) / div;
int g2 = (factor * g - r - b) / div;
int b2 = (factor * b - r - g) / div;
pix[0] = col(r2);
pix[1] = col(g2);
pix[2] = col(b2);
pix += 3;
}
}