About picture Loading frames

Source: Internet
Author: User
Tags webp

Next, this article begins a comparative summary of the popular third-party picture loading frameworks that are now being compared.

This article describes the following:

1. What is the current popular picture loading framework?

2, the use of their respective methods

3. Advantages and disadvantages of each

4, optimization problems

What is the current popular picture loading framework?

 Imageloader Glide Picasso Fresso (2015)

Note: This blog post will no longer be elaborated due to the low use of imageloader now. Mainly in the other three framework-based, interested students can learn by themselves.

Ii. respective methods of use

  Picasso:   

  Picasso                . With (this)                . Load ("Picture address")                //Convert picture size                . Resize (100,100)                //similar to the ScaleType property                . Centercrop ()                //occupies bitmap                . Placeholder (r.mipmap.ic_launcher)                //error message diagram                . Error (R.mipmap.ic_launcher)                . into (ImageView);

  

Glide: (The method of use is basically consistent with Picasso)

Fresco:

  <com.facebook.drawee.view.simpledraweeview android:id= "@+id/my_image_view" android:layout_width= "20DP"        android:layout_height= "20DP" fresco:fadeduration= "fresco:actualimagescaletype=" Focuscrop " Fresco:placeholderimage= "@color/colorprimary" fresco:placeholderimagescaletype= "Fitcenter" fresco:failureIm Age= "@mipmap/ic_launcher" fresco:failureimagescaletype= "Centerinside" fresco:retryimage= "@mipmap/ic_launcher "Fresco:retryimagescaletype=" Centercrop "fresco:progressbarimage=" @mipmap/ic_launcher "Fresco:progre Ssbarimagescaletype= "Centerinside" fresco:progressbarautorotateinterval= "fresco:backgroundimage=" @colo R/colorprimary "fresco:overlayimage=" @mipmap/ic_launcher "fresco:pressedstateoverlayimage=" @color/colorprima Ry "fresco:roundascircle=" false "fresco:roundedcornerradius=" 1DP "fresco:roundtopleft=" true "f Resco:roundtopright= "FalSe "fresco:roundbottomleft=" false "fresco:roundbottomright=" true "fresco:roundwithoverlaycolor=" @colo R/colorprimary "fresco:roundingborderwidth=" 2DP "fresco:roundingbordercolor=" @color/colorprimary "/&G T

Fresco Property Description:

1. The width and Height properties must be set, and the two properties do not know how to blow wrap_content, and the width height must be set.

2, support the aspect ratio, through The Viewaspectratio property specifies the aspect ratio, fixed width or height, and the other can be set to Wrap_content

3,placeholderimage and Placeholderimagescaletype, set the zoom type for bitmaps and bitmaps

4, Roundascircle = True is set to a circular chart

5. Roundedcornerradius Fillet

6, Roundwithoverlaycolor background fixed to the specified color

Initialize when loading pictures with fresco (recommended for initialization in application)

Fresco.  Initialize(this);
Loading images can be achieved by Setimageuri:
     Draweeview.  Setimageuri(uri);

Fresco all attributes almost support in the code to modify, if necessary, the specific need to see the official documentation, written in very detailed.
(Note: All the above is officially listed, only some of the commonly used properties to explain.) My demo is running under 0.12.0, when I do, the version is low cause some properties are not supported, note the version of the problem Oh.
To allow fresco to support WEBP format images, you must introduce dependent dependencies)

Iii. advantages and disadvantages of each

First of all, any kind of framework will not be absolutely perfect, as long as it is suitable for you, is the best. Therefore, when you choose to use the framework, be sure to understand its advantages and disadvantages, combined with the project you want to choose.

Picasso:

Advantages:

1, Picasso default loading picture format is argb_8888, high image clarity.

2, in the adapter need to cancel already not in the field of view of the ImageView picture resource loading, otherwise it will cause the picture dislocation, Picasso has solved the problem

3. Use complex image compression conversions to reduce memory consumption as much as possible

4. Self-memory and HDD level two cache function

Disadvantages:

1, every time the cache, regardless of the size of the ImageView, it will default to cache the entire picture, when displayed always need to adjust the size

2, can not load GIF diagram, the load is not movable

3, Fillet diagram requires a custom converter, and then specified by the transform method, and the display is not good, or has a raw edge

Glide:

  Advantages:

1, Picasso with the method can only be passed to the context object, and glide can be transmitted context, Activity, fragmentactivity, fragment and so on.

The benefit of this is that the loading of the picture can be consistent with the activity or fragment declaration cycle. Stop loading when the activity or fragment is destroyed.

2, glide default load format is rgb_565, it consumes only half of the memory of argb_8888

3, it will be based on the size of ImageView picture cache more than one picture, loading speed, better than Picasso, equivalent to use space to exchange time

4, Support GIF graph (memory consumption, use with caution)

5, fillet chart effect than Picasso good

6, another feature is that you can configure the animation of the picture display, and Picasso only one animation: fading in.

7, you can use thumbnail () to produce a picture you have loaded thumbnail.

Disadvantages:

  1, the loading format is rgb_565, no Picasso picture effect is good (but the naked eye can not distinguish, you may choose to use this method to optimize your project, reduce memory consumption)

。。。。

(The number of methods for Picasso and glide are 840 and 2,678 respectively.) It must be noted that 2678 is a fairly large number for the 65,535 methods of the Dex file. It is recommended to turn on Proguard when using glide. )

Summary: Glide and Picasso are not perfect, in some ways, glide in the image of the cache is relatively good, because it is faster, in addition, it
can also effectively prevent oom errors, and loading GIF pictures is also a big advantage of glide, but by default the picture quality of Picasso is very high.
Another tip is to use glide to change the format of the picture to ARGB8888 and cache the full size and other dimensions of the picture, so that it can be better to load the picture.

Fresco

Claiming to be the most powerful picture loading frame of Android so far, the main advantage of his is that it has better memory management and more powerful functions than other frameworks.
Advantages:
1, memory management, to achieve a true sense of level three cache, two-level memory cache and a disk cache. The two-level memory cache is a cache of bitmap caches and uncompressed images, which speeds up the loading of pictures. It is also worth mentioning that when the app switches to the background, the fresco
Automatically cleans up the two-level memory cache without the need for manual
2, support flow style, can be similar to the fuzzy progressive display image on the page
3, for multi-frame animation picture support better, such as GIF and WEBP (large map of the boot interface with the WEBP put in the drawable, with the fresco load can)

(Note: Today's picture loading problem summary is mainly for the introduction of WEBP, it is a new image format, many sites are currently in use, interested can continue to pay attention to)
Disadvantages:
Volume is larger compared to other frames, and is usually introduced to cause the app's apk to increase 1.5M to 2M

(In fact, I think, relative to the advantages of fresco, this drawback is not what the ~ of course, if your project only the picture show, I feel the glide or Picasso slightly do some optimization is enough)

Iv. Optimization Issues

There are only a few optimization methods to choose from, depending on your needs:

1, need high-quality pictures, not satisfied with the glide rgb_565

  

public class Glideconfiguration implements Glidemodule {    @Override public    void Applyoptions (context context, Glidebuilder builder) {        //Apply options to the builder here.        Builder.setdecodeformat (decodeformat.prefer_argb_8888);    }    @Override public    void registercomponents (context context, Glide Glide) {        //register modelloaders here.    }}

  

Then define Glidemodule as Meta-data in Androidmanifest.xml

<meta-data android: Name="Com.inthecheesefactory.lab.glidepicasso.GlideConfiguration" Android: Value="Glidemodule"/>         

2, about Glide

The above mentioned glide will cache the size of different size pictures, when your page imageview changes, it will request a corresponding size of the picture, and cache, load. Thus, depending on the size of the ImageView, the same sheet

The picture will be cached several times, but this will greatly increase the load speed, which is to use space in exchange for time. The Picasso only caches a full size, and then, depending on the size of the ImageView, it is resized and then loaded, so that the speed is much slower.

In order to avoid glide multiple access to the network download problem, you can cache a full size map, and then appear in different sizes, by adjusting the full-size diagram for the cache loading.

Glide.with (this).     load ("")     . Diskcachestrategy (Diskcachestrategy.all). to     ();

Picasso is displayed by resizing, so there are some delays that can be set to display immediately (the effect is not obvious)

Picasso.nofade ();

3, Picasso and glide can configure the size of the picture cache control! Appropriate adjustments can be made according to your needs.

Finally, recommend an article about Picasso source parsing, written very good

Http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0731/1639.html

About picture Loading frames

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.