Created
April 23, 2011 22:25
-
-
Save lahwran/939036 to your computer and use it in GitHub Desktop.
color multiplication
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
public int colorMult(int x, int y) | |
{ | |
int res = 0; | |
for (int octet = 0; octet < 3; octet++) | |
{ | |
int shift = (8*octet); | |
int xoct = (x & (0xff << shift)) >> shift; | |
int yoct = (y & (0xff << shift)) >> shift; | |
xoct *= yoct; | |
xoct /= 0xff; | |
res += xoct << shift; | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment