android – How to get width and height of the image?-ThrowExceptions

Exception or error:


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 ?

How to solve:


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


I have follow this link :-

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

Leave a Reply

Your email address will not be published. Required fields are marked *