Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to get the Rect in which Bitmap is drawn on Android?

I am trying to subclass ImageView and draw something on Bitmap. However I cannot find a way to get the Rect in which Bitmap is drawn. I can only get the Rect in which ImageView is drawn by getDrawingRect(Rect) method of ImageView. Below is an illustration of what I want to get:

enter image description here

The Rect I want is the blue one. Thanks in advance.

like image 238
ipman Avatar asked Jan 28 '12 13:01

ipman


1 Answers

The given image will be drawn in the ImageView based on the attributes given e.g., height, width, scaling factors, etc.

So that the getDrawingRect() method giving the entire area of ImageView. If you change the drawable inside ImageView the blue colored area may change based on the image properties and imageview properties. But the yellow colored area won't change because it is fixed and based on the ImageView only, its independent of image displayed.

I think no chance to get the Rect of bitmap drawn. Don't think my answer is 100% correct, it is just a suggestion only.

You may get information about blue colored area from Drawing Cache. Try it once.

I hope it may help you.

like image 74
Yugandhar Babu Avatar answered Sep 20 '22 12:09

Yugandhar Babu