davemorrissey/subsampling-scale-image-view

How to compute scale for fitting the image's height?

Closed this issue · 1 comments

Hi,

I am trying to display landscape images, first by showing them entirely, then by zooming on the left part, so that the height of the image fits the view.

I use setMinimumScaleType(SCALE_TYPE_CENTER_INSIDE, and then i perform an animation to zoom:

animateScaleAndCenter(10F, PointF(0F, 0F))!!
                            .withDuration(500)
                            .withEasing(EASE_IN_OUT_QUAD)
                            .withInterruptible(true)
                            .start()

However, I don't know what scale to pass to animateScaleAndCenter.

If i pass a very large number, like 10F, it will zoom too much, and I won't see the bottom part of the image.

If i pass a small number, like scale * 2, it won't zoom enough sometimes (depending on the image size), and the displayed height would not fit the view height.

How can i compute the right scale to pass, so that the image height will fit the view?

Thanks

view.height / view.sHeight did the trick.