Created
March 15, 2016 11:40
-
-
Save alxsimo/60b195ba4ac761a5d922 to your computer and use it in GitHub Desktop.
[Android] Convert image to bytes[] array with Glide
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 static byte[] generateByteArrayProfileImage(Context context, Uri uri) | |
throws ExecutionException, InterruptedException { | |
int width = Constantes.PROFILE_IMAGE_SIZE_WIDTH; | |
int height = Constantes.PROFILE_IMAGE_SIZE_HEIGHT; | |
return Glide.with(context.getApplicationContext()) | |
.load(uri) | |
.asBitmap() | |
.toBytes(Bitmap.CompressFormat.JPEG, 70) | |
.centerCrop() | |
.into(width, height) | |
.get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment