Detailed explanation of Android learning notes

Source: Internet
Author: User

Package xiaosi. roundconcer; import android. app. activity; import android. graphics. bitmap; import android. graphics. bitmap. config; import android. graphics. bitmapfactory; import android. graphics. canvas; import android. graphics. paint; import android. graphics. porterduff. mode; import android. graphics. porterduxfermode; import android. graphics. rect; import android. graphics. rectf; import android. OS. bundle; import android. widget. imageview; public class roundconceractivity extends activity {/** called when the activity is first created. */private imageview roundimage = NULL; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); roundimage = (imageview) findviewbyid (R. id. roundconcer); Bitmap bitmap = bitmapfactory. decoderesource (getresources (), R. drawable. a); roundimage. setimagebitmap (getroundcornerimage (bitmap, 50);} public static bitmap getroundcornerimage (Bitmap bitmap, int roundpixels) {// create a bitmap roundconcerimage = bitmap, which is the same as the original image. createbitmap (bitmap. getwidth (), bitmap. getheight (), config. argb_8888); // create a canvas with a bitmap roundconcerimage = new canvas (roundconcerimage); // create a paint brush paint = new paint (); // create a rectangle rect = new rect (0, 0, bitmap. getwidth (), bitmap. getheight (); rectf = new rectf (rect); // de-sawtooth paint. setantialias (true); // draw a rectangle canvas of the same size as the original image. drawroundrect (rectf, roundpixels, roundpixels, paint); // you can specify the Intersection Mode paint. setxfermode (New porterduduxfermode (mode. src_in); // draw the image to the rectangle to canvas. drawbitmap (bitmap, null, rect, paint); Return roundconcerimage ;}}
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: 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.