Convert Bytes to Bitmap - Android Graphics

Android examples for Graphics:Bitmap Byte Array

Description

Convert Bytes to Bitmap

Demo Code


//package com.book2s;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import java.io.ByteArrayInputStream;

import java.io.InputStream;

public class Main {

    public final static Bitmap Bytes2Bitmap(byte[] b) {
        if (b == null) {
            return null;
        }/*from w w w.  j a v  a2  s.  c om*/
        if (b.length != 0) {
            InputStream is = new ByteArrayInputStream(b);
            Bitmap bmp = BitmapFactory.decodeStream(is);
            return bmp;
        } else {
            return null;
        }
    }
}

Related Tutorials