我有一个可以拍照并将其存储到 SD 卡的应用程序,但是我拍摄的每张照片都经过了极度压缩,质量非常低。我以完整质量压缩它,所以我不确定为什么要这样做。有什么建议么?这是代码:
protected void takePhoto()
{
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
currPhoto = (ImageView) findViewById(R.id.imageView1);
if (requestCode== 0 && resultCode == Activity.RESULT_OK){
Bitmap x = (Bitmap) data.getExtras().get("data");
currPhoto.setImageBitmap(x);
ContentValues values = new ContentValues();
values.put(Images.Media.MIME_TYPE, "image/jpeg");
Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
OutputStream outstream;
try {
outstream = getContentResolver().openOutputStream(uri);
x.compress(Bitmap.CompressFormat.JPEG, 90, outstream);
outstream.close();
} catch (FileNotFoundException e) {
//
}catch (IOException e){
//
}
}
}
编辑:事实上它似乎只将缩略图保存到 SD。
最佳答案
来自documentation :
public static final String
ACTION_IMAGE_CAPTURE
Added in
API level 3
Standard Intent action that can be sent to have the camera application capture an image and return it.The caller may pass an extra
EXTRA_OUTPUT
to control where this image will be written. If theEXTRA_OUTPUT
is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If theEXTRA_OUTPUT
is present, then the full-sized image will be written to the Uri value ofEXTRA_OUTPUT
.
关于java - 拍照并保存到 SD 而不会降低质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15857777/