How do I get the raw dimensions of a bitmap in an ImageView?

Posted by potatoe on Stack Overflow See other posts from Stack Overflow or by potatoe
Published on 2010-12-24T04:47:50Z Indexed on 2010/12/24 4:54 UTC
Read the original article Hit count: 158

Filed under:
|

It seems like I might be overlooking something obvious, but I can't figure out how to retrieve the raw (unscaled) dimensions of a bitmap being displayed in an ImageView.

For example, if I load a bitmap using Bitmap b = BitmapFactory.decodeResource(...), I can get those dimensions from b.getWidth() and b.getHeight(), and I could pass the bitmap into an ImageView using setImageBitmap(b). But if I have a subclass of ImageView, is there any way to retrieve those dimensions without having to pass them in explicitly? I guess I'm looking for a getImageBitmap() analog of ImageView's setImageBitmap() method, which would retrieve a Bitmap object that I can call getWidth() and getHeight() on. Any other way to retrieve the original dimensions would work too, though.

© Stack Overflow or respective owner

Related posts about android

Related posts about imageview