Android Reduce Size Of Camera Picture

后端 未结 2 1670
时光取名叫无心
时光取名叫无心 2020-12-05 08:47

UPDATE maybe changing the Bitmap size in the new Activity may fix the problem

String myRef = this.getIntent().getStringExtra(\"filepath\");
         


        
2条回答
  •  -上瘾入骨i
    2020-12-05 09:38

    Try this capturing image from Camera.

    Intent cameraActivity=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                cameraActivity.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(left));
                startActivityForResult(cameraActivity,CAMERA_PIC_REQUEST_LEFTIMAGE);
    

    This will return you large size image , now for scaling it down u can use something like this

        BitmapFactory.Options options=new BitmapFactory.Options();
                            options.inSampleSize = 6;
                            FileInputStream fileInputStream;    
                            try {
                                    fileInputStream=new FileInputStream(left);
                                    leftPhoto=BitmapFactory.decodeStream(fileInputStream,null,options);
                                    leftImage.setImageBitmap(leftPhoto);
                                    fileInputStream.close();
                                } catch (FileNotFoundException e) {
                                    Toast.makeText(getCurrentContext(), e.getMessage(),Toast.LENGTH_LONG).show();
                                    e.printStackTrace();
                                } catch (IOException e) {
                                    e.printStackTrace();
                                    Toast.makeText(getCurrentContext(), e.getMessage(),Toast.LENGTH_LONG).show();
                                }
    

    Now u can add on click on this .

提交回复
热议问题