创建bitmap另一种方式

来源:互联网 发布:设计数据库的软件 mac 编辑:程序博客网 时间:2024/06/11 13:43
Bitmap target = Bitmap.createBitmap(size, size, getConfig(bitmap));
       int width = Math.round(scale * bitmap.getWidth());
       int height = Math.round(scale * bitmap.getHeight());
       Canvas canvas = new Canvas(target);
       canvas.translate((size - width) / 2f, (size - height) / 2f);//偏移,也可以旋转之类操作
       canvas.scale(scale, scale);
       Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
       canvas.drawBitmap(bitmap, 0, 0, paint);
原创粉丝点击