我尝试做到这一点:
Bitmap bitmapOrg = BitmapFactory.decodeFile("/sdcard/"+ photoName + ".jpg");
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width,
height, matrix, true);
FileOutputStream os;
try {
os = new FileOutputStream(String.format(
"/sdcard/" + photoName + "-rotate.jpg",
System.currentTimeMillis()));
resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, os);
因为旋转后的文件分辨率=96 dpi,而原始文件为72 dpi,所以旋转后的文件大小>原始文件大小。那么这是为什么呢?如何修复这个问题?
100
的质量,这可能会导致输出比输入更大。 - Chris Cashwell