2. Picture decode need time, the bigger the picture, the more details of the picture, then it decode time is longer
3. The stupidest thing to do is, when the picture is decode, we show that the black background will be seen before the decode is finished. But
This approach is not very friendly, especially when the big picture, the longer the waiting time
In order to give customers a better user experience, we will first decode a picture of the thumbnail is the thumbnail, when we click on a
After the image comes in, we first see the thumbnail of the image so that the user knows that the picture is displayed
However, because the resolution of the thumbnail is limited, it will be blurred after being posted on the screen. That's why the first sight of the mold
The reason for the paste
4. At this time, still can not escape decode the whole picture of the steps, we are fully able to wait for the entire picture decode completed before
Update to the screen.
But we don't think this way is too good, why not decode out part of the show?
So finally the method is: We divide the whole picture into small pieces (tiles), high resolution pictures, tile size
Is 510, the tile size of the normal picture is 254, then we follow from top to bottom, from left to right in order decode
Tile, so you see the picture a small piece of a small piece of the display, the picture is gradually becoming clear process
So, at the moment this program has been optimized, just because the decode need time, we can not do a show clear
Picture, or shorten the time when the picture becomes clear.
void Updatefromconfiguration (context context, resources resources, int wPx, int hPx, int awpx, int ahpx) { Configu Ration configuration = Resources.getconfiguration (); Islandscape = (Configuration.orientation = = Configuration.orientation_landscape); Istablet = Resources.getboolean (r.bool.is_tablet); Islargetablet = Resources.getboolean (r.bool.is_large_tablet); if (Android.os.Build.VERSION.SDK_INT >= Android.os.Build.VERSION_CODES. JELLY_BEAN_MR1) { Islayoutrtl = (configuration.getlayoutdirection () = = View.layout_direction_rtl); } else { Islayoutrtl = false; } WIDTHPX = wPx; HEIGHTPX = hPx; AVAILABLEWIDTHPX = AWPX; AVAILABLEHEIGHTPX = ahpx; Updateavailabledimensions (context); }
Image double-click to change large algorithm
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 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) Assuming 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.
Reprint Please specify source: Zhou Mushi's csdn blog Http://blog.csdn.net/zhoumushui