Skip to content

Instantly share code, notes, and snippets.

@pmcfernandes

pmcfernandes/Sepia.java

Last active Sep 17, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.