Skip to content

Instantly share code, notes, and snippets.

@lahwran
Created April 23, 2011 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lahwran/939036 to your computer and use it in GitHub Desktop.
Save lahwran/939036 to your computer and use it in GitHub Desktop.
color multiplication
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