Android Image double-click algorithm for magnification

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.