The picture double-clicks the magnification and the picture size, displays the picture the view size, and the picture current scale size all has the relation.
To avoid a magnified image, set the maximum limit for a magnification of scale_limit, which is currently 4.
The specific algorithm is as follows:
Picture width and height are recorded as: Imagew Imageh
The view width and height of the displayed picture are as follows: Vieww VIEWH
A few important proportions are recorded as:
Scale_1 = Vieww/imagew
scale_2 = Viewh/imageh
Scale_3 = Vieww/imageh
Scale_4 = Viewh/imagew
If the width-to-height ratio of the current picture is >2 or <0.5, the magnification zoomrate is calculated according to the following algorithm:
(1) The current scale = min (scale_1, scale_2);
(2) zoomrate = min (max (scale_1, scale_2), Max (Scale_3, scale_4));
(3) If zoomrate > Scale_limit, then zoomrate = Scale_limit;
(4) If scale >= zoomrate, the result of preserving (1) recalculates the Zoomrate value from step (2), otherwise jumps to (6)
Zoomrate = Max (max (Scale_1, scale_2), Max (Scale_3, scale_4));
(5) If zoomrate > Scale_limit, then zoomrate = Scale_limit;
(6) The Zoomrate value is the multiple of the image that should be enlarged.
If the width-to-height ratio of the current picture is <=2 or >=0.5, the magnification zoomrate is calculated according to the following algorithm:
(1) The current scale = min (scale_1, scale_2);
(2) largerinitrate = max (min (scale_1, scale_2), Min (Scale_3, scale_4));
(3) If largerinitrate > Scale_limit, then largerinitrate = Scale_limit;
(4) zoomrate = min (scale_2, largerinitrate * 2.0f);
(5) If zoomrate > Scale_limit, then zoomrate = Scale_limit;
(6) If scale >= zoomrate, the result of the first 3 steps is retained, the Zoomrate value is recalculated from step (4), otherwise jumps to (8)
Zoomrate = Largerinitrate * 2.0f;
(7) If Zoomrate > Scale_limit, then zoomrate = Scale_limit;
(8) The Zoomrate value is the multiple of the image that should be enlarged.
Android Image double-click algorithm for magnification