我需要做以下事情:
我正好做这3个步骤...... 问题是图像以小尺寸(160 x 120)保存。 当我从相机获得结果时,我这样做:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
Log.i("Test", "Width: " + photo.getWidth() + " Height: " + photo.getHeight());
返回
Width: 160 Height: 120
我从“数据”变量得到的图像是1280 x 960 ......
如果我使用
background= Bitmap.createScaledBitmap(background, 1280, 960, false);
我得到的图像质量差......
如何获得合适大小的位图?!
答案 0 :(得分:2)
尝试将图像写入文件,然后返回文件名作为结果:
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFile = new File(filename);
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
} catch (Exception e) {
}
Intent intent = this.getIntent();
intent.putExtra("filename", filename);
this.setResult(RESULT_OK, intent);
finish();
}