Skip to content

Instantly share code, notes, and snippets.

@pmcfernandes
Last active September 17, 2016 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmcfernandes/8261130 to your computer and use it in GitHub Desktop.
Save pmcfernandes/8261130 to your computer and use it in GitHub Desktop.
public Bitmap ConvertToSepia(Bitmap sampleBitmap){
float[] sepMat = {
0.3930000066757202f,
0.7689999938011169f,
0.1889999955892563f,
0,
0,
0.3490000069141388f,
0.6859999895095825f,
0.1679999977350235f,
0,
0,
0.2720000147819519f,
0.5339999794960022f,
0.1309999972581863f,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1};
ColorMatrix sepiaMatrix = new ColorMatrix();
sepiaMatrix.set(sepMat);
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(sepiaMatrix);
Bitmap rBitmap = sampleBitmap.copy(Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setColorFilter(colorFilter);
Canvas myCanvas = new Canvas(rBitmap);
myCanvas.drawBitmap(rBitmap, 0, 0, paint);
return rBitmap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment