【问题标题】:capture photo inside app with original resolution in android在android中以原始分辨率在应用程序内捕获照片
【发布时间】:2014-08-14 14:44:33
【问题描述】:

我正在使用相机意图在我的 android 应用程序中捕获图像。捕获后,我将照片保存到特定文件夹中的移动内部/外部存储中。问题是这些照片没有以相机通常具有的分辨率保存,它们的分辨率非常低。

这是我的代码

Intent intent = new Intent(
                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 0); 

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        Bitmap bp = (Bitmap) data.getExtras().get("data");

        /*********** Load Captured Image And Data Start ****************/
        String extr = Environment.getExternalStorageDirectory().toString()
                + File.separator + "ScannerMini";
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
                .format(new Date());
         imageName = timeStamp + ".jpg";

        if (Environment.MEDIA_MOUNTED.equals(state)) {
            // We can read and write the media
            myPath = new File(getExternalFilesDir(filepath), imageName);
            //File myPath = new File(extr, imageName);
        }
        else{
         myPath = new File(extr, imageName);
        }
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(myPath);
            bp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();

            MediaStore.Images.Media.insertImage(getApplicationContext()
                    .getContentResolver(), bp, myPath.getPath(), imageName);

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

谁能告诉我我应该怎么做才能以原始分辨率保存图像。任何帮助将非常感激。谢谢你:)

【问题讨论】:

    标签: android android-intent android-camera


    【解决方案1】:
    Bitmap bp = (Bitmap) data.getExtras().get("data");
    

    这样做你只会得到一个缩略图。您需要在捕获意图中指定 MediaStore.EXTRA_OUTPUT 选项。这是存储捕获图像的路径。参考安卓文档Taking Photos Simply

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-18
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      • 2011-06-05
      • 2016-05-08
      • 1970-01-01
      • 2015-05-14
      相关资源
      最近更新 更多