Skip to content

Instantly share code, notes, and snippets.

@akuafif
Created December 10, 2015 20:58
Show Gist options
  • Save akuafif/19ab4aa6cf0aac3c89e7 to your computer and use it in GitHub Desktop.
Save akuafif/19ab4aa6cf0aac3c89e7 to your computer and use it in GitHub Desktop.
[Java/Android] Convert a Picture from an ImageView into GrayScale
// Convert Imageview to grayscale
private void convertToGrayScale(ImageView imageView, boolean convert) {
if (!convert) {
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageView.setColorFilter(filter);
} else {
imageView.setColorFilter(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment