【问题标题】:Get better quality picture from camera从相机获得更好质量的图片
【发布时间】:2013-04-17 08:51:41
【问题描述】:

我在 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 兆像素拍照。

有没有办法在不需要手动相机的情况下做到这一点?

【问题讨论】:

    标签: java android android-camera


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多