如何在Android中的SD卡上保存全尺寸照片

时间:2014-01-06 11:07:12

标签: android image

我正在从相机拍照并将其保存在SD卡上。但保存图像会比实际图片小。任何人都可以帮我存储全尺寸照片。我正在使用以下代码

  button.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        Intent intent1 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent1, RESULT_LOAD_IMAGE1);
    }
});

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE1 && resultCode == RESULT_OK
        && null != data) {

    custId = cid.getText().toString();

    Bitmap bm = (Bitmap) data.getExtras().get("data");
    try {
        File f1 = new File(Environment.getExternalStorageDirectory(),"photo.png");
        f1.createNewFile();
        FileOutputStream fs = new FileOutputStream(f1);
        bm.compress(CompressFormat.PNG, 100, fs);
        fs.flush();
        fs.close();
        photoPath = f1.getAbsolutePath();

    } catch (Exception e) {
        e.printStackTrace();
    }

1 个答案:

答案 0 :(得分:1)

你是对的。查看已经提供的Android Doc