Android Utililty Methods Bitmap Encode

List of utility methods to do Bitmap Encode

Description

The list of methods to do Bitmap Encode are organized into topic(s).

Method

StringgenerateEncodedUrlForImage(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;
StringgenerateEncodedUrlForImage(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;
StringgenerateEncodedUrlForImage(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 {
...