当我从相机拍摄照片时,我得到的图像大小为300-500 K.B(1800 X 1700像素)。Android:将位图的大小调整为更大的像素宽度和高度
但是,当我从我的应用程序拍照时,我得到一个大小为30-50 K.B(150 X 200像素)的图像。
如何将150 x 200像素大小调整为像300 x 400像素?
因为我发送此图像的服务器将不接受小于280 x 360像素尺寸的图像。
我现在使用的代码是:
Bitmap bit = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte[] ba = bao.toByteArray();
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "My - Images");
File f = new File(imagesFolder, "test.jpg");
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(ba);
fo.flush();
fo.close();
我没有压缩的图像,但我仍然获得10次较小的图像尺寸相比图像使用相机从主屏幕取。
谢谢
我已经将它保存在SD卡上。我应该将它保存为临时文件吗?现在它永久保存 –