Skip to content

Instantly share code, notes, and snippets.

@danieldiekmeier
Created June 4, 2014 13:50
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 danieldiekmeier/60c3e22bb8704d738acf to your computer and use it in GitHub Desktop.
Save danieldiekmeier/60c3e22bb8704d738acf to your computer and use it in GitHub Desktop.
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