Android Image processing--zoom

Source: Internet
Author: User

PS: In the development we will encounter some image processing problems, such as cache pictures, limit the size of the image, view pictures and so on. The previous article introduced the picture of panoramic effect view, today introduced a picture zoom, if we have time, we can write a library of their own, which will use the view of the press, event distribution, gestures and other knowledge, if there is no time or no other way, Take a look at this photoview. This is a picture zoom library, for such a gitview and so on, below I will introduce some usage. Function:
    • Load picture normally
    • Double click to enlarge
    • Random gesture Zoom
    • Drag to view every corner of a picture
    • Combine other settings to enable rollover

1: Local picture loading
<imageview        android:layout_width= "match_parent"        android:layout_height= "300DP"        android:id= "@+id/ Id_loc "        android:scaletype=" Fitxy "        />
<uk.co.senab.photoview.photoview        android:layout_width= "match_parent"        android:layout_height= "400DP"        android:src= "@mipmap/ic_launcher"        android:id= "@+id/id_myimg"/>
The first method:
Local Load Method One        //Set picture        drawable bitmap = Getresources (). getdrawable (R.mipmap.ic_launcher);        Loc.setimagedrawable (bitmap);        Connected in Photoview        photoviewattacher mattacher = new Photoviewattacher (loc);        Mattacher.update ();//update
The second Kind
Local method Load two        photoviewattacher mattacher;       Mattacher = new Photoviewattacher (loc);       Iv.setimagebitmap (bitmap);        Glide.with (this). Load (R.mipmap.ic_launcher). Asbitmap (). to (Loc);        Mattacher.update ();
2: Network picture loading

For the network can also be used ImageView and photoview two kinds of

It is OK to add the object name of ImageView or Photoview directly to display.

        Load network picture        Imageloader loader= imageloader.getinstance ();        Loader.init (Imageloaderconfiguration.createdefault (imagetest.this))//loader Initialize        loader.displayimage ("https ://ss0.bdstatic.com/94ojfd_baact8t7mm9gukt-xh_/timg?image&quality=100&size=b4000_4000&sec= 1529211252&di=1414331e22239ecb5730cbbd0f3793eb&src=http://pic154.nipic.com/file/20180114/26629113_ 090329120799_2.jpg ", loc);//Display pictures

Below we can look at the source code, in fact, he also inherited the ImageView

/** * Adds display image task to execution pool. Image is set to ImageView when it ' s turn. <br/> * Default {@linkplain displayimageoptions display image Options} from {@linkplain imageloaderconfiguration * C  Onfiguration} would be used.<br/> * <b>NOTE:</b> {@link #init (imageloaderconfiguration)} method must be Called before this method call * * @param the URI       Image uri (i.e. "Http://site.com/image.png", "file:///mnt/sdcard/image. PNG ") * @param imageView {@link ImageView} which should display image * @throws illegalstateexception    If {@link #init ( Imageloaderconfiguration)} method wasn ' t called before * @throws illegalargumentexception if passed <b>imageview& Lt;/b> is null */public void DisplayImage (String uri, ImageView ImageView) {displayimage (URI, new Imageviewaware (image View), NULL, NULL, NULL);}

Finish

Android Image processing--zoom

Related Article

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.