added desaturate function for making greyed out icons

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@793 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-12-29 19:38:09 +00:00
parent d2196eea09
commit 4602d46203
2 changed files with 15 additions and 0 deletions
+3
View File
@@ -95,6 +95,9 @@ void mask_blend(Image& img1, const Image& img2, const Image& mask);
/// Saturate an image, amount should be in range [0...100]
void saturate(Image& image, int amount);
/// Desaturate an image
void desaturate(Image& image);
// ----------------------------------------------------------------------------- : Combining
/// Ways in which images can be combined, similair to what Photoshop supports
+12
View File
@@ -30,3 +30,15 @@ void saturate(Image& image, int amount) {
pix += 3;
}
}
void desaturate(Image& image) {
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];
pix[0] = (r+r+g+b) / 4;
pix[1] = (g+r+g+b) / 4;
pix[2] = (b+r+g+b) / 4;
pix += 3;
}
}