Created
August 10, 2016 08:39
-
-
Save lgarczyn/6f24c8ada7fbc1412d0e35be3dcbd219 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
unsigned int color_average(unsigned int a, unsigned int b) | |
{ | |
unsigned int ra = a & 0xFF0000; | |
unsigned int rb = b & 0xFF0000; | |
unsigned int ga = a & 0xFF00; | |
unsigned int gb = b & 0xFF00; | |
unsigned int ba = a & 0xFF; | |
unsigned int bb = b & 0xFF; | |
unsigned int r = (ra / 2 + rb / 2) & 0xFF0000; | |
unsigned int g = (ga / 2 + gb / 2) & 0xFF00; | |
unsigned int b = (ba / 2 + bb / 2) & 0xFF; | |
return r | g | b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment