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.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    public static int[] getImageSize(Context context, int drawableId) {
        Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), drawableId);
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        if (bitmap != null && bitmap.isRecycled()) {
            bitmap.recycle();
        }
        int size[] = { width, height };
        return size;
    }
}