1、BitmapFactory类,该类是Android API提供工具类,可以将将图片文件转换为bitmap对象
2、图片的放大缩小,通过Martix对象的postScale()方法实现手机上缩放图片的功能。
// 产生放大后的Bitmap对象 Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); iv.setImageBitmap(createBitmap);
3、图片的旋转,通过Martix对象的setRotate()方法可实现图片的旋转
// 向左旋转 scaleAngle--; if (scaleAngle < -10) { scaleAngle = -10; } Matrix matrix = new Matrix(); matrix.postScale(width, height); matrix.setRotate(5 * scaleAngle); Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); iv.setImageBitmap(createBitmap);