Decode string to Bitmap - Android Graphics

Android examples for Graphics:Bitmap String

Description

Decode string to Bitmap

Demo Code


//package com.java2s;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

public class Main {
    public static Bitmap stringtoBitmap(String string) {
        // ??????????Bitmap??
        Bitmap bitmap = null;//from www .j  av  a 2s.  com
        try {
            byte[] bitmapArray;
            bitmapArray = Base64.decode(string, Base64.DEFAULT);
            bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
                    bitmapArray.length);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bitmap;
    }
}

Related Tutorials