我试图通过调整图像的长度和宽度来减小图像的大小,但它以兆字节为单位保持相同的大小,有时它甚至更大,即使它只有一半大。
String compressPath = Environment.getExternalStorageDirectory()+"/test2.jpg";
FileInputStream in = new FileInputStream(path);
Bitmap fullSizeBitmap = BitmapFactory.decodeStream(in);
Bitmap resized = Bitmap.createScaledBitmap(
fullSizeBitmap,
(int)(fullSizeBitmap.getWidth()*0.5),
(int)(fullSizeBitmap.getHeight()*0.5),
true
);
FileOutputStream mOutputStream = new FileOutputStream(compressPath);
resized.compress(Bitmap.CompressFormat.PNG, 100, mOutputStream);
有什么问题?我必须降低质量吗?