Android Bitmap圆角
代码如下:
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2; Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
source.recycle();
} Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig()); Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
paint.setShader(shader);
paint.setAntiAlias(true); float r = size/2f;
canvas.drawCircle(r, r, r, paint); squaredBitmap.recycle();
return bitmap;
}
Android Bitmap圆角的更多相关文章
- Android bitmap图片处理
一.View转换为Bitmap 在Android中所有的控件都是View的直接子类或者间接子类,通过它们可以组成丰富的UI界面.在窗口显示的时候Android会把这些控件都加载到内存中 ...
- Android 圆形/圆角图片的方法
Android 圆形/圆角图片的方法 眼下网上有非常多圆角图片的实例,Github上也有一些成熟的项目.之前做项目,为了稳定高效都是选用Github上的项目直接用.但这样的结束也是Android开发必 ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- Android Bitmap 和 ByteArray的互相转换
Android Bitmap 和 ByteArray的互相转换 移动平台图像处理,需要将图像传给native处理,如何传递?将bitmap转换成一个 byte[] 方便传递也方便cpp代码直接处理图像 ...
- Android——BitMap(位图)相关知识总结贴
Android中文API(136) —— Bitmap http://www.apkbus.com/android-54644-1-1.html Android 4.0 r1 API—Bitmap(S ...
- Android Bitmap 全面解析(四)图片处理效果对比 ...
对比对象: UIL Volley 官方教程中的方法(此系列教程一里介绍的,ImageLoader的处理方法和官方的差不多) -------------------------------------- ...
- 36、Android Bitmap 全面解析
Android Bitmap 全面解析(一)加载大尺寸图片 http://www.eoeandroid.com/thread-331669-1-1.html Android Bitmap 全面解析(二 ...
- Android Bitmap 载入与像素操作
Android Bitmap 载入与像素操作 一:载入与像素读写 在Android SDK中,图像的像素读写能够通过getPixel与setPixel两个Bitmap的API实现. Bitmap AP ...
- android bitmap compress(图片压缩)
android bitmap compress android的照相功能随着手机硬件的发展,变得越来越强大,能够找出很高分辨率的图片. 有些场景中,需要照相并且上传到服务,但是由于图片的大小太大,那么 ...
随机推荐
- slave延迟原因及优化方法
转载叶总:http://imysql.com/2015/04/12/mysql-optimization-case-howto-resolve-slave-delay.shtml 一般而言,slave ...
- yii2 访问控制
class SiteController extends Controller{ /** * @inheritdoc */ public function behaviors() { return [ ...
- 【转载】solr教程,值得刚接触搜索开发人员一看
转载:http://blog.csdn.net/awj3584/article/details/16963525 Solr调研总结 开发类型 全文检索相关开发 Solr版本 4.2 文件内容 本文介绍 ...
- C# ?? 运算符,不能忘记的知识点
最近项目中有一个bug被测试(是黑盒测试)发现了,跟了老半天代码,才找到这个问题的所在,原来是一个计算表达式中用到了??运算符,才导致了这个错误,下面让我简单讲述一下. C# ?? 运算符 msdn上 ...
- PLSQL在cmd命令行中的基本用法
首先:set serveroutput on:设置打印 declareresult number;beginselect (sal*12)+nvl(comm,0) into result from e ...
- stopWeblogic时提示错误以及无法关闭服务
执行: y@y:~/oracle/middleware/user_projects/domains/yshy_domain/bin$ ./stopWebLogic.sh 错误信息如下: Stoppin ...
- bzoj2100 [Usaco2010 Dec]Apple Delivery
Description Bessie has two crisp red apples to deliver to two of her friends in the herd. Of course, ...
- bzoj1644 [Usaco2007 Oct]Obstacle Course 障碍训练课
Description 考虑一个 N x N (1 <= N <= 100)的有1个个方格组成的正方形牧场.有些方格是奶牛们不能踏上的,它们被标记为了'x'.例如下图: . . B x . ...
- poj 1001 求高精度幂
本题的测试用例十分刁钻,必须要考虑到很多的细节问题,在这里给出一组测试用例及运行结果: 95.123 12 548815620517731830194541.899025343415715973535 ...
- Climbing Stairs 解答
Question You are climbing a stair case. It takes n steps to reach to the top. Each time you can eith ...