mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user