Example usage for android.graphics BitmapFactory decodeByteArray

List of usage examples for android.graphics BitmapFactory decodeByteArray

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeByteArray.

Prototype

public static Bitmap decodeByteArray(byte[] data, int offset, int length) 

Source Link

Document

Decode an immutable bitmap from the specified byte array.

Usage

From source file:Main.java

public static Bitmap getImageFromByteArray(byte[] picture) {
    Bitmap bmp;// w ww  .  java  2 s  .  c om
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inMutable = true;
    bmp = BitmapFactory.decodeByteArray(picture, 0, picture.length);//, options);
    return bmp;
}

From source file:Main.java

public static Bitmap convertBase64ToBitmap(String strBase64) {
    byte[] imageAsBytes = Base64.decode(strBase64.getBytes(), Base64.DEFAULT);
    Bitmap result = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);
    return result;
}

From source file:Main.java

public static Bitmap base64ToBitmap(String base64) {
    if (base64 != null && !base64.isEmpty()) {
        byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
        Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        return decodedByte;
    }//from w w w  . j  a v a 2s. com
    return null;
}

From source file:Main.java

/**
 * Converts compressed byte array to bitmap
 * @param src source array//from   ww  w.j  a  v a2 s.  co  m
 * @return result bitmap
 */
public static Bitmap convertCompressedByteArrayToBitmap(byte[] src) {
    return BitmapFactory.decodeByteArray(src, 0, src.length);
}

From source file:Main.java

public static Bitmap decodeByteArray(byte[] data, int offset, int length) {
    return BitmapFactory.decodeByteArray(data, offset, length);
}

From source file:Main.java

public static Bitmap getBitmap(Context context, String str) {
    if (str != null && str.length() > 0) {
        byte[] decode = Base64.decode(str, Base64.DEFAULT);
        return BitmapFactory.decodeByteArray(decode, 0, decode.length);
    }/*  w w w . ja  v  a2s. co  m*/
    return null;
}

From source file:Main.java

public static Bitmap convertStringToIcon(String st) {
    Bitmap bitmap = null;//from   w w  w. j av  a 2  s. co m
    try {
        byte[] bitmapArray;
        bitmapArray = Base64.decode(st, Base64.DEFAULT);
        bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
        return bitmap;
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

public static Bitmap stringToBitmap(String string) {
    Bitmap bitmap = null;/* w w w  . j a va 2 s .c o m*/
    try {
        byte[] bitmapArray;
        bitmapArray = Base64.decode(string, Base64.DEFAULT);
        bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap convertStringToBitmap(String string) {
    Bitmap bitmap = null;/*  w  w  w  .j a v  a  2 s  .  c  om*/
    try {
        byte[] bitmapArray;
        bitmapArray = Base64.decode(string, Base64.DEFAULT);
        bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return bitmap;
}

From source file:Main.java

/**
 * Method to convert a byte[] into a Bitmap.
 *
 * @param b The byte[] passed as parameter.
 * @return The converted Bitmap.//from  w  w w . j  av a 2  s.  com
 */
public static Bitmap fromByteArraytoBitmap(byte[] b) {
    return BitmapFactory.decodeByteArray(b, 0, b.length);
}