implemented more image related functions

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@59 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-29 22:13:11 +00:00
parent f46b0b6b7b
commit 601af4c778
11 changed files with 377 additions and 33 deletions
+31
View File
@@ -0,0 +1,31 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 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;
}
}