您的位置:首页 > 其它

创建bitmap另一种方式

2013-05-15 14:10 239 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: