Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.InputStream;

import android.graphics.BitmapFactory;

public class Main {
    public static int[] getImageWidhtHeightFromFilePath(String filePath) {
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            File imageFile = new File(filePath);
            InputStream is = new FileInputStream(imageFile);
            BitmapFactory.decodeStream(is, null, options);
            return new int[] { options.outWidth, options.outHeight };
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}