Android fillet Picture

Source: Internet
Author: User

Android fillet Picture

Import android.app.Activity;
Import Android.app.AlertDialog;
Import Android.content.BroadcastReceiver;
Import Android.content.Context;
Import Android.content.DialogInterface;
Import android.content.Intent;
Import Android.content.IntentFilter;
Import android.content.SharedPreferences;
Import Android.content.SharedPreferences.Editor;
Import Android.graphics.Bitmap;
Import Android.graphics.Bitmap.Config;
Import Android.graphics.Canvas;
Import Android.graphics.Paint;
Import Android.graphics.PorterDuff.Mode;
Import Android.graphics.PorterDuffXfermode;
Import Android.graphics.Rect;
Import Android.graphics.RectF;
Import android.graphics.drawable.BitmapDrawable;
Import android.graphics.drawable.Drawable;
Import Android.os.Bundle;
Import Android.telephony.TelephonyManager;
Import android.view.KeyEvent;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.EditText;
Import Android.widget.ImageView;
Import Android.widget.Toast;

public class Mainactivity extends Activity {


@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Yuanjiaotupian ();
}

private void Yuanjiaotupian () {
TODO auto-generated Method Stub
ImageView IV = (ImageView) Findviewbyid (R.id.iv_main_yuanjiao);
drawable drawable = Getresources (). getdrawable (R.DRAWABLE.ASD);
Bitmapdrawable bitmapdrawable = (bitmapdrawable) drawable;
Bitmap Bitmap = Bitmapdrawable.getbitmap ();
bitmapdrawable bd = new bitmapdrawable (Toroundcorner (bitmap, 30));
Iv.setbackgrounddrawable (BD);
}

/**
* Method of obtaining rounded bitmap
*
* @param bitmap
* Bitmaps that need to be converted into rounded corners
* @param pixels
* The size of the fillet, the larger the value, the bigger the fillet
* @return rounded bitmap after processing
*/
public static Bitmap Toroundcorner (Bitmap Bitmap, int pixels) {
Bitmap output = Bitmap.createbitmap (Bitmap.getwidth (),
Bitmap.getheight (), config.argb_8888);
Canvas canvas = new canvas (output);
final int color = 0xff424242;
Final Paint paint = new paint ();
Final rect rect = new Rect (0, 0, bitmap.getwidth (), Bitmap.getheight ());
Final RECTF RECTF = new RECTF (rect);
Final float roundpx = pixels;
Paint.setantialias (TRUE);
Canvas.drawargb (0, 0, 0, 0);
Paint.setcolor (color);
Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint);
Paint.setxfermode (New Porterduffxfermode (mode.src_in));
Canvas.drawbitmap (Bitmap, rect, rect, paint);
return output;
}

}

Android fillet Picture

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.