converts string to bitmap. - Android Graphics

Android examples for Graphics:Bitmap String

Description

converts string to bitmap.

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.util.Base64;

public class Main {
    /**/*from w w w . j av  a  2s.co m*/
     * This method converts string to bitmap.
     * 
     * @param bitmapString
     * @return
     */
    @SuppressWarnings("unused")
    public static Bitmap StringToBitMap(String bitmapString) {
        try {
            byte[] byteArray = Base64.decode(bitmapString, Base64.DEFAULT);
            Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0,
                    byteArray.length);
            return bitmap;
        } catch (Exception e) {
            return null;
        }
    }
}

Related Tutorials