Get Bitmap's Width - Android Graphics

Android examples for Graphics:Bitmap Size

Description

Get Bitmap's Width

Demo Code


//package com.java2s;

import android.content.res.Resources;

import android.graphics.BitmapFactory;

public class Main {
    /** Get Bitmap's Width **/
    public static int getBitmapOfWidth(Resources res, int id) {
        try {/*from   w  ww. ja va2 s. c o m*/
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeResource(res, id, options);
            return options.outWidth;
        } catch (Exception e) {
            return 0;
        }
    }
}

Related Tutorials