简体   繁体   English

位图质量很低

[英]Bitmap quality is very low

I'm trying to build an app, that captures a picture and sends the picture to another activity. 我正在尝试构建一个应用程序,该应用程序捕获一张图片并将该图片发送到另一个活动。 I'm trying to display this picture in the second activity and apparently the quality of picture is very low. 我正在尝试在第二个活动中显示此图片,显然图片的质量很低。

Here is my code so far 到目前为止,这是我的代码

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, PICTURE_TAKEN);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        super.onActivityResult(requestCode, resultCode, data);      

        if(resultCode == RESULT_OK){
            Intent canvasIntent = new Intent(this ,canvas.class);

            Bundle extras = data.getExtras();
            bmpCameraResult = (Bitmap)extras.get("data");
            canvasIntent.putExtra("bmp_Image", bmpCameraResult);            
            startActivity(canvasIntent);                

        }

and in the canvasActivity, I'm trying to receive the bitmap in the conventional fashion and trying to display it. 在canvasActivity中,我试图以常规方式接收位图并尝试显示它。

Intent intent= getIntent();
        Bitmap bmp = (Bitmap) intent.getParcelableExtra("bmp_Image");
        ImageView iv = new ImageView(this);        
        iv.setImageBitmap(bmp);      
        setContentView(iv);

What could be the reason for this reduction of quality? 降低质量的原因可能是什么? What is the optimized way of getting the high quality image? 获得高质量图像的优化方法是什么?

Thank You. 谢谢。

Did you try to set jpegQuality ( setJpegQuality ) in your Camera Parameters ( Camera.Parameters ) as you can read here: Camera Feature Documentation ? 您是否尝试Camera ParametersCamera.Parameters )中设置jpegQualitysetJpegQuality ),如在此处阅读的内容: 相机功能文档

I think you should also read these answers about the same issue: 我认为您也应该阅读有关同一问题的以下答案:

  1. Android: Not able to get original photo captured by camera (Able to read compress photo only) Android:无法获取相机拍摄的原始照片(只能读取压缩照片)
  2. Low picture/image quality when capture from camera 从相机拍摄时图片/图像质量低

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM