Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 CanvasDrawUtils.java
 Copyright (c) 2015 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    /**
     * Gets a bitmap from data.
     *
     * @param data data
     * @return Bitmap or null on error
     */
    public static Bitmap getBitmap(final byte[] data) {
        if (data != null) {
            try {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inMutable = true;
                return BitmapFactory.decodeByteArray(data, 0, data.length, options);
            } catch (OutOfMemoryError e) {
                return null;
            }
        }
        return null;
    }
}