Created
June 4, 2014 13:50
-
-
Save danieldiekmeier/60c3e22bb8704d738acf to your computer and use it in GitHub Desktop.
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
private void sepiaImage(int[] origPixels, int[] pixels, int width, int height) | |
{ | |
for (int y=0; y<height; y++) { | |
for (int x=0; x<width; x++) { | |
int pos = y*width + x; | |
int argb = origPixels[pos]; // Lesen der Originalwerte | |
int r = (argb >> 16) & 0xff; | |
int g = (argb >> 8) & 0xff; | |
int b = argb & 0xff; | |
int gamma = (r+g+b)/3; | |
r = gamma + 30; | |
g = gamma + 10; | |
b = gamma - 10; | |
if (r > 255) { | |
r = 255; | |
} | |
if (g > 255) { | |
g = 255; | |
} | |
if (b < 0) { | |
b = 0; | |
} | |
int rn = r; | |
int gn = g; | |
int bn = b; | |
pixels[pos] = (0xFF<<24) | (rn<<16) | (gn<<8) | bn; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment