Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static Bitmap getBitmap(String imagePath, int inSampleSize) {
        if (imagePath == null) {
            return null;
        }
        if (inSampleSize == 0) {
            inSampleSize = 1;
        }

        Bitmap bmp = null;
        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
        opts.inSampleSize = inSampleSize;
        bmp = BitmapFactory.decodeFile(imagePath, opts);

        return bmp;
    }

    public static final Bitmap getBitmap(String imagePath) {
        if (imagePath == null) {
            return null;
        }

        Bitmap bitmap = getBitmap(imagePath, 8);

        return bitmap;
    }
}