Commit 17319f04 authored by twanvl's avatar twanvl

added desaturate function for making greyed out icons

parent e2b66891
...@@ -95,6 +95,9 @@ void mask_blend(Image& img1, const Image& img2, const Image& mask); ...@@ -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] /// Saturate an image, amount should be in range [0...100]
void saturate(Image& image, int amount); void saturate(Image& image, int amount);
/// Desaturate an image
void desaturate(Image& image);
// ----------------------------------------------------------------------------- : Combining // ----------------------------------------------------------------------------- : Combining
/// Ways in which images can be combined, similair to what Photoshop supports /// Ways in which images can be combined, similair to what Photoshop supports
......
...@@ -30,3 +30,15 @@ void saturate(Image& image, int amount) { ...@@ -30,3 +30,15 @@ void saturate(Image& image, int amount) {
pix += 3; 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment