0
我有一個2550x3300大小的JPEG文件(此文件是用質量級別90創建的)。該文件的物理大小爲2.5 MB。我想將這個圖像縮小到1288x1864(原始尺寸的50%)並保存爲相同的質量90.但是,我希望事先知道下采樣圖像的物理尺寸,即使在實際縮小尺寸之前。縮小圖像的大小預測
任何幫助表示讚賞!
這裏是我使用的代碼,
`
//Decodes the existing file to bitmap
Bitmap srcBP = BitmapFactory.decodeFile(filePath, options);
//Calculates required width and height
int reqWidth = options.outWidth * .50;
int reqHeight = options.outHeight * .50;
//Creates scaled image
Bitmap outBP = Bitmap.createScaledBitmap(srcBP, reqWidth, reqHeight, false);
//Save modified as JPEG
File tempFile = new File(imageOutPath);
FileOutputStream out = new FileOutputStream(tempFile);
outBP.compress(Bitmap.CompressFormat.JPEG, compression, out);
out.close();
`