我的代码:
final Uri fileUri = null;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, 2);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Uri final = getImageUri((Bitmap) data.getExtras().get("data"));
final String filePath = getPath(final);
}
}
获取图像uri:
public Uri getImageUri(Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(this.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
此后,我的图像质量不好
我该如何解决?
谢谢
答案 0 :(得分:1)
这是由于压缩而发生的。如果您真的需要压缩,请尝试使用:
Bitmap bitmapScaled = Bitmap.createScaledBitmap(inImage, width, height, true);
也请在这里看看,也许您会找到更适合自己的东西:
https://developer.android.com/training/camera/photobasics#java