Created
April 22, 2012 19:25
-
-
Save wjlafrance/2466303 to your computer and use it in GitHub Desktop.
Processing pixels stored in 32-bit integers as AARRGGBB to create a negative image
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
//Slow: | |
int r = (pixels[i] & 0x00FF0000 >> 16) * -1 + 255; | |
int b = (pixels[i] & 0x0000FF00 >> 8) * -1 + 255; | |
int g = (pixels[i] & 0x000000FF) * -1 + 255; | |
pixels[i] = r << 16 | b << 8 | g; | |
//Fast: | |
pixels[i] ^= 0x00FFFFFF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment