我通过 Android 在 Android 中拍照
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, CAMERA_REQUEST);
并通过以下方式显示/保存
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
ImageView theImage = (ImageView) findViewById(R.id.preview);
theImage.setImageBitmap(photo);
// try to save its
try {
File testFile = new File(Environment.getExternalStorageDirectory(), "test.png");
testFile.createNewFile();
FileOutputStream out = new FileOutputStream(testFile);
photo.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
效果很好,但图像质量很差。我不知道为什么,因为我用 8 兆像素拍摄照片。
有没有一种方法可以在不需要手动使用相机的情况下做到这一点?
最佳答案
仔细看看this帖子:Android 中有两种捕获图像的方法。第一个设计用于拍摄小而轻的照片 - 这就是您使用的方法,第二个捕获全尺寸的照片并将其写入存储。该帖子描述了完成此任务的两种方法。
关于java - 从相机获得更高质量的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16055642/