Android保存的图像质量低下

Android保存的图像质量低下,第1张

Android保存的图像质量低下

请调用以下功能从相机捕获图像。

 private final static String FOLDER_NAME = "YourAppName/Image/"; private Uri selectedImageUri = null;public void startCamera()     {        File photo = null;        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))         { photo = new File(android.os.Environment.getExternalStorageDirectory(), FOLDER_NAME+File.separator+timeStamp+".png");        }         else         { photo = new File(getCacheDir(), FOLDER_NAME+File.separator+timeStamp+".png");        } if (photo != null)         { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); selectedImageUri = Uri.fromFile(photo); startActivityForResult(intent, CAPTURE_IMAGE_CALLBACK);        }    }

您可以在selectedImageUri变量中获取图像Uri。(图像存储在SD卡中)

    protected void onActivityResult(int requestCode, int resultCode, Intent data)     {        switch (requestCode)         { case CAPTURE_IMAGE_CALLBACK:     break;          }     }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5462233.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存