Android Image double-click algorithm for magnification

Source: Internet
Author: User

The picture double-clicks the magnification and the picture size, displays the picture's view size. and the current scale size of the image are related.
In order to avoid the image enlargement too large. Sets the maximum limit for a magnification of scale_limit, which is now 4.

Detailed algorithms such as the following are seen:
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

Assuming the width-to-height ratio of the current picture is >2 or <0.5, the magnification zoomrate is computed according to the algorithm such as the following:
(1) The current scale = min (scale_1, scale_2).
(2) zoomrate = min (max (scale_1, scale_2), Max (Scale_3, scale_4));
(3) Assuming zoomrate > scale_limit, then zoomrate = Scale_limit;
(4) Assuming scale >= zoomrate, the result of preserving (1) calculates the Zoomrate value again from step (2), otherwise jumps to (6)
Zoomrate = Max (max (Scale_1, scale_2), Max (Scale_3, scale_4));
(5) Assuming zoomrate > scale_limit, then zoomrate = Scale_limit;
(6) The Zoomrate value is the multiple of the image that should be enlarged.



Assuming the width-to-height ratio of the current picture is <=2 or >=0.5, the magnification zoomrate is computed according to the algorithm such as the following:
(1) The current scale = min (scale_1, scale_2).
(2) largerinitrate = max (min (scale_1, scale_2), Min (Scale_3, scale_4));
(3) Assuming largerinitrate > scale_limit, then largerinitrate = Scale_limit;
(4) zoomrate = min (scale_2, largerinitrate * 2.0f);
(5) Suppose zoomrate > Scale_limit. Then zoomrate = Scale_limit;
(6) Assuming scale >= zoomrate, the results of the first 3 steps are retained, and the Zoomrate value is computed again from step (4), otherwise jumps to (8)
Zoomrate = Largerinitrate * 2.0f;
(7) Assuming 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.