ramsbh
ramsbh

Reputation: 656

How to get width and height of the image?

HI,

I want to get width and height of the image which i was stored in the drawable folder. Is this possible, if so please let me know ?

Upvotes: 23

Views: 38186

Answers (2)

duggu
duggu

Reputation: 38439

I have follow this link :-

Drawable d = getResources().getDrawable(R.drawable.yourimage);
int h = d.getIntrinsicHeight();
int w = d.getIntrinsicWidth();

Upvotes: 15

Jett Hsieh
Jett Hsieh

Reputation: 3159

try

BitmapDrawable bd=(BitmapDrawable) this.getResources().getDrawable(R.drawable.icon);
int height=bd.getBitmap().getHeight();
int width=bd.getBitmap().getWidth();

Upvotes: 62

Related Questions