Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Image width that has been scaled

enter image description here

  • The Actual image source height = 180px and width = 192px
  • The ImageView is 90px width and 60 px heigth.

I want to know the Actual image height and width as how it is being displayed on the screen. Can somebody help me?

i tried the following but it didn't gave me the results i was looking for

  • if i do imageview.getWidth i get the 90px of the ImageView
  • if i do the imageView.getMeasuredWidth i get the 90px of the ImageView
  • if i do imageview.getDrawable.getIntrinsicWidth i get the actual source width of 192px
  • if i do imageview.getDrawable.getBounds i get the actual source width of 192px
  • if i retrieve the bitmap and do getScaledWidth(metrics) i get the actual asource width of 192px
like image 733
EvertvdBraak Avatar asked Aug 07 '12 13:08

EvertvdBraak


1 Answers

You can try something like this:

  • you have Image height (IH) and image width (IW)
  • find ImageView height (H).
  • find the top padding (TP) and bottom padding (BP) for the ImageView
  • your displayed image height is DIH = H - (BP + TP)
  • displayed image width DIW = (IW * DIH) / IW;

I hope I understand your question.

like image 73
Zelter Ady Avatar answered Nov 09 '22 09:11

Zelter Ady