从相机获得更高质量的图片

时间:2013-04-17 08:51:41

标签: java android android-camera

我通过

在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百万像素拍照。

有没有办法在不需要手动摄像机的情况下执行此操作?

1 个答案:

答案 0 :(得分:3)

仔细查看this帖子:有两种方法可以在Android中捕获图像。第一个用于拍摄小而轻的图片 - 这是您使用的方法,第二个用于捕获全尺寸图片并将其写入存储。这篇文章描述了完成这项任务的两种方式。

相关问题