List of utility methods to do Bitmap Encode
String | generateEncodedUrlForImage(Bitmap bitmap) Generates a base64 encoded data URI from the provided Bitmap if (bitmap != null) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream); byte[] bitMapData = stream.toByteArray(); return generateEncodedUrlForImage(bitMapData); } else { return null; |
String | generateEncodedUrlForImage(Drawable drawable) Generates a Base64 encoded data URI from the provided Drawable if (drawable != null && drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); return generateEncodedUrlForImage(bitmap); } else { return null; |
String | generateEncodedUrlForImage(byte[] bitMapData) Generates a base64 encoded data URI from the provided byte array if (bitMapData != null) { try { return "data:image/jpg;base64," + Base64.encodeToString(bitMapData, Base64.NO_WRAP); } catch (AssertionError assertionError) { return null; } else { ... |