Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

import android.graphics.*;

import java.io.InputStream;

public class Main {
    public static final Bitmap getBitmapFromRaw(Context context, int resId) {
        if (resId <= 0)
            return null;
        try {
            InputStream is = context.getResources().openRawResource(resId);
            BitmapFactory.Options imageOptions = new BitmapFactory.Options();
            Bitmap bmp = BitmapFactory.decodeStream(is, null, imageOptions);
            return bmp;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
}