我必须将从相机/图库中捕获的图像上传到服务器。在许多应用程序中,我看到分辨率为1000X560的图像大小为35 KB。而在我的情况下,图像大小高达380 KB。我的手机相机拍摄的图像分辨率为2368X4224,大小小于2 MB。如何保持图像的高分辨率同时使其大小低?以下是我迄今为止尝试过的方法:
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(realPath, bmOptions);
bmOptions.inSampleSize = 1;
bmOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
bmOptions.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(realPath, bmOptions);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
我已经阅读过这篇文档。我面临的问题是如何决定图像的最小宽度和最小高度。