Android Bitmap Picture frame effect processing contrast (Essence VI)

Source: Internet
Author: User

Compare objects: UIL Volley The method in the official tutorial (as described in this series of tutorials, the imageloader approach is the same as the official one)

------------------------------------------------------------------------

The first single image compression processing, but also the focus of the analysis of a small demo (the end will release the download connection) will be the corresponding calculation method copy out, and then calculated dozens of sets of data, the original width is a 10000 of a random integer, the limit size is 400 200, Then compression processing, recorded 10 sets of data as follows <ignore_js_op>

The control scaling type Fit_inside and crop are detailed in the UIL Framework analysis in tutorial three-1, where it's easy to say Fit_inside is the default control display type, and the picture is displayed completely inside the control, not necessarily filling the control crop is making the picture fill the entire control, The picture may not show the full effect. You can build a ImageView in Android project without setting the zoom type (ie fit_inside effect), then build a scaletype to crop the same size control, and then display the same picture, you will see the difference between



The official/volley/imageloader does not differentiate between scaling types, so the final compressed image is a size result under different scaling types, and we can clearly see that the official algorithm is the same as the UIL crop type, In essence, the effect is to ensure that the image width and height after compression is greater than or equal to the limit of the width of the volley, the kind of special treatment of the limited value, then the final effect is to let the compressed picture width of any one greater than or equal to the width of the high can be, the corresponding UIL fit_inside effect



What kind of good? (only for compression processing of pictures) UIL we have a long and detailed analysis (tutorial series three-1), for the scaling type of processing is very accurate, is obviously the best ~ (so many people use is not unreasonable) that contrast, the official processing and volley of each have insufficient ~

Official =uil CROP That is the official method of handling is more suitable for CROP zoom type of picture display However, when dealing with a large difference in aspect ratio of the picture, if the fit_inside display mode, it will result in a slightly larger compressed picture, although the display quality can be guaranteed, But waste a small amount of memory resources such as the first set of data, 664 3640 of the compression results, obviously and we need 400 200 difference is too large-brain repair is probably the match box and Watermelon knife bar (not too accurate ~)

Volley=uil Fit_inside on behalf of volley more suitable for the picture display by default, so when dealing with a picture with a wide aspect ratio that is too large, if it is a crop scale type, the compression size looks pretty much the same, but actually the display does not work as expected. Size we can see it from the size value, show the effect I still have to make a real picture of the people look at it (you can download the demo project at the end of the article)



Desperate to find a microblog long chart experiment, the project altogether four ImageView control, the above two is volley, the bottom row is UIL, the left two is fit_inside effect, the right is crop and I said volley in too big wide height difference, With the crop type display can not achieve the expected quality of the effect, is the upper right corner of this figure, it is simply that I do not wear glasses to see the world drops in comparison, UIL in the treatment of crop the effect is very secure ~<ignore_js_op>

The above shortcomings have a condition wide and high ratio difference is too large, because most of the case, the original image of the aspect ratio is relatively stable, and we limit the value is similar, most of the situation is set to a square of the limited size, the original image is almost square rectangle ~ This explains why most of the picture frames, including the official tutorials, do not specifically differentiate between different zoom types, because, in general, where the length-to-width ratio is not stable, the official type of simple processing is the applicable reference to the above data we can also be drawn, when the original length and width ratio and the limit aspect ratio of the more similar, Then two different algorithms (official and UIL crop is one, volley and UIL Fit_inside is another) the smaller the difference, when the original image and the limit value of the aspect ratio is very similar or even equal, the two algorithms will eventually be the same (such as the red bold part of the data) And we look at the difference between the length and width of the first group of data and the second-to-last group of data, the difference between the two algorithms is directly 2^4=16 times ~ Everyone is interested in trying to get some of the larger proportion of the special value to try

------------------------------------------------------------------------

Picture color style comparison volley wrote Dead is Rgb_565imageloader no settings, that should be the default Argb_8888uil provisioning API, the default is also argb_8888

------------------------------------------------------------------------

Cache pool comparison volley only interface ... None of the instance classes, but it's easy to write. Imageloader is mainly Tanqiang reference, single soft reference two UIL offers 8 types, weak and strong, separate and mixed, including different algorithms

The difference lies in the difference between soft and weak references, this direct look at tutorial two for different reference types of introduction on the line, you can also Baidu search, in fact, the difference is not strong reference parts are similar, even using the latest LRUCache class, Actually look at the source code we will also find inside or with LINKEDHASHMAP implementation

------------------------------------------------------------------------


In summary, it must be UIL completely win, there are a lot of expansion function part is also UIL more powerful did not run
But volley framework we have said before, although the function is not perfect, but very suitable for us two times development
Imageloader, a little bit simpler, you can learn the source of the small practiced hand to use


------------------------------------------------------------------------

Last drop Finally, the demo is a brief introduction under the Drawable package has a large aspect ratio of the micro-bo long map, there is a normal close to the square diagram, code only one class, the inside of several compression algorithms are posted out, the test method has been written, we can modify the numerical calculation, You can also copy some pictures to see the effect of other proportions of the picture layout file corresponding to only one, the inside put 4 ImageView, two ordinary, two center_crop, that is, the corresponding crop scaling type, control scaling type and UIL frame scaling type of the corresponding relationship, Refer to tutorial three-1 in UIL Introduction

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.