Android Saved images are low quality

前端 未结 2 521
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-24 16:19

I\'m taking pictures through the following code and saving to SD card, but the pictures that it produces are such low quality and really bitty even with 100% quality. Maybe bitm

2条回答
  •  故里飘歌
    2021-01-24 16:46

    Please call the below function to capture image from camera.

     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);
            }
        }
    

    You can get image Uri in selectedImageUri variable . (Image is stored in Sdcard)

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

提交回复
热议问题