Last active
September 17, 2016 14:59
-
-
Save pmcfernandes/8261130 to your computer and use it in GitHub Desktop.
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
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