图像相机质量差
Image camera quality is bad
我的代码:
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);
}
在这之后,我的图像质量很差
我该如何解决?
谢谢
发生这种情况是因为压缩。如果你真的需要压缩它尝试使用:
Bitmap bitmapScaled = Bitmap.createScaledBitmap(inImage, width, height, true);
请也看看这里,也许你能找到更适合你的东西:
https://developer.android.com/training/camera/photobasics#java
我的代码:
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);
}
在这之后,我的图像质量很差
我该如何解决?
谢谢
发生这种情况是因为压缩。如果你真的需要压缩它尝试使用:
Bitmap bitmapScaled = Bitmap.createScaledBitmap(inImage, width, height, true);
请也看看这里,也许你能找到更适合你的东西:
https://developer.android.com/training/camera/photobasics#java