Android Fillet picture Implementation

Source: Internet
Author: User

The picture shows when the total sense of the right angle of the picture is not good to see? That's a good idea! ~ ~

 Public classToroundcornerextendsactivity{ PublicBitmap Toroundcorner (Bitmap Bitmap,intpixels) {Bitmap Output=Bitmap.createbitmap (Bitmap.getwidth (), Bitmap.getheight (), Bitmap.Config.ARGB_8888); Canvas Canvas=NewCanvas (output); Final intcolor = 0xff424242; FinalPaint paint =NewPaint (); FinalRect rect =NewRect (0, 0, Bitmap.getwidth (), Bitmap.getheight ()); FinalRECTF RECTF =NewRECTF (rect); Final floatROUNDPX =pixels; Paint.setantialias (true); Canvas.drawargb (0, 0, 0, 0);        Paint.setcolor (color);        Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint); Paint.setxfermode (NewPorterduffxfermode (PorterDuff.Mode.SRC_IN));        Canvas.drawbitmap (Bitmap, rect, rect, paint); returnoutput; }}

Put the above code in the toolkit as needed, just call it!

ImageView pic = (ImageView) navigationview.getheaderview (0). Findviewbyid (R.id.tou_pic); TextView username= (TextView) navigationview.getheaderview (0). Findviewbyid (R.id.nav_username); TextView Phone= (TextView) navigationview.getheaderview (0). Findviewbyid (R.id.nav_phone); //convert a picture into a bitmapDrawable drawable =getresources (). getdrawable (R.mipmap.aboutus); Bitmapdrawable bitmapdrawable=(bitmapdrawable) drawable; Bitmap Bitmap=Bitmapdrawable.getbitmap (); //turn a picture into rounded cornersToroundcorner Toround =NewToroundcorner (); Pic.setimagebitmap (Toround.toroundcorner (bitmap,50));

It's easy to use, isn't it? One of the last lines Toround.toroundcorner (bitmap, bitmap) is the picture to be passed in, and the larger the next number, the more visible the rounded corners.

Method excerpt from: Scripting House (http://www.jb51.net/article/32320.htm)

Android Fillet picture Implementation

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.