Bitmap bm = BitmapFactory.decodeResource(context.getResources(),R.drawable.xxx);
//原始尺寸
int width=bm.getWidth();
int height=bm.getHeight();
//缩放比例
float scaleHeight=((float)120)/height;
float scaleWidth=scaleHeight;
// 创建操作图片用的matrix对象
Matrix matrix = new Matrix();
// 缩放图片动作
matrix.postScale(scaleWidth, scaleHeight);
//旋转图片 动作
//matrix.postRotate(45);
// 创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bm,0,0,width, height,matrix,true); Android入门之图片缩放
最新推荐文章于 2015-03-22 11:15:45 发布
本文介绍了如何使用Java代码实现图片的缩放和旋转功能,包括获取图片原始尺寸、设置缩放比例、创建操作图片用的矩阵对象以及生成新的图片。
556

被折叠的 条评论
为什么被折叠?



