Created
May 9, 2012 20:43
-
-
Save tebriel/2648652 to your computer and use it in GitHub Desktop.
DesaturateColor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int DesaturateColor(int seatColor, int remainingSaturation, int targetColor) | |
{ | |
int justR = (seatColor & 0xFF0000); | |
justR -= (targetColor << 16); | |
int r = ((justR * remainingSaturation) / 100) + (targetColor << 16); | |
r &= 0xFF0000; | |
int justG = (seatColor & 0x00FF00); | |
justG -= (targetColor << 8); | |
int g = (justG * remainingSaturation) / 100 + (targetColor << 8); | |
g &= 0x00FF00; | |
int justB = (seatColor & 0x0000FF); | |
justB -= targetColor; | |
int b = (justB * remainingSaturation) / 100 + targetColor; | |
b &= 0x0000FF; | |
return r | g | b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment