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, Options opts) 

Source Link

Document

Decode an immutable bitmap from the specified byte array.

Usage

From source file:Main.java

private static void decodeBounds(Options options, byte[] data) {
    options.inJustDecodeBounds = true;/*from   w w  w .  java2  s.  c om*/
    BitmapFactory.decodeByteArray(data, 0, data.length, options);
}

From source file:Main.java

public static Bitmap decodeByteArray(byte[] bytes, BitmapFactory.Options opts) {
    if (bytes != null)
        if (opts != null)
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opts);
        else/*from  w  ww . j  a  v  a 2 s . c o m*/
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    return null;
}

From source file:Main.java

public static Bitmap getBitmapFromBytes(byte[] bytes, BitmapFactory.Options opts) {
    if (bytes != null) {
        if (opts != null) {
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opts);
        } else {/*ww  w . j  a va  2s .  com*/
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
        }
    }

    return null;
}

From source file:Main.java

/**
 * byte[] -> Bitmap/*from ww w  . j  a  va  2s.c om*/
 * 
 * @param bytes
 * @return
 */
public static Bitmap byteToBitmap(byte[] bytes) {
    Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, null);
    return bitmap;
}

From source file:Main.java

public static BitmapFactory.Options getBitmapDimesions(byte[] img) {

    // Make sure the bitmap is not stored in memory!
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;/*from w  w w  .  j a va2 s  . c  om*/

    BitmapFactory.decodeByteArray(img, 0, img.length, options);

    return options;
}

From source file:Main.java

public static Bitmap getPicFromBytes(byte[] bytes, BitmapFactory.Options opts) {
    if (bytes != null)
        if (opts != null)
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opts);
        else//w w  w.j  a  v  a 2s .  c om
            return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    return null;
}

From source file:Main.java

public static Bitmap decodeVideoBitmap(byte[] data, int reqHeight) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 6;/*  w  w w.j  a  v a2  s.c  o  m*/
    options.inJustDecodeBounds = false;
    return BitmapFactory.decodeByteArray(data, 0, data.length, options);
}

From source file:Main.java

public static Bitmap getBitmapFromBytes(byte[] data) {
    if (data == null || data.length == 0)
        return null;

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inMutable = true;//  w w w. ja v  a  2  s .  c o  m

    return BitmapFactory.decodeByteArray(data, 0, data.length, options);
}

From source file:Main.java

/**
 * getImage from byte array//from w  w w.j  a va 2s .  co  m
 * @param image
 * @return BitMap image
 */
public static Bitmap getImage(byte[] image) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 2;
    return BitmapFactory.decodeByteArray(image, 0, image.length, options);
}

From source file:Main.java

/**
 * byte[] -> Drawable//from  w ww.j a va2  s.co  m
 * 
 * @param bytes
 * @return
 */
public static BitmapDrawable byteToDrawable(byte[] bytes) {
    Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, null);
    BitmapDrawable bd = new BitmapDrawable(bitmap);
    bitmap.recycle();
    bitmap = null;
    return bd;
}