一.装载图片
BitmapFactory.decodeFile(pathName);
二.缩放图片
Matrix matrix = new Matrix();??
matrix.reset();
float scaleWidth = ((float) 320) / bitmap.getWidth();
float scaleHeight = ((float) 240) / bitmap.getHeight();
matrix.postScale(scaleWidth, scaleHeight);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
三.旋转图片
Matrix matrix = new Matrix();?
matrix.reset();
matrix.postRotate(180);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,true);
四.保存图片
File file = new File(path);
FileOutputStream outStream = null;
try
{
outStream = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 100, outStream);
???outStream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
?
原文:https://blog.51cto.com/u_15298588/3034034