get Picture From Bytes using BitmapFactory - Android android.graphics

Android examples for android.graphics:BitmapFactory

Description

get Picture From Bytes using BitmapFactory

Demo Code

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class Main{

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

}

Related Tutorials