Android 将相机中的图像保存到imageView时质量下降

Android 将相机中的图像保存到imageView时质量下降,android,bitmap,camera,imageview,png,Android,Bitmap,Camera,Imageview,Png,我正在尝试创建一个应用程序,用户可以使用相机拍照并将其保存到指定文件夹。但是,当它从imageView转换为PNG文件时,会严重降低质量 我认为使用这段代码可以确保质量保持较高 bmap.compress(Bitmap.CompressFormat.PNG, 100, output); 但即使我将质量从100改为更低的数字,我也看不出有什么区别 if (requestCode == cameraData && resultCode == RESULT_OK

我正在尝试创建一个应用程序,用户可以使用相机拍照并将其保存到指定文件夹。但是,当它从imageView转换为PNG文件时,会严重降低质量

我认为使用这段代码可以确保质量保持较高

bmap.compress(Bitmap.CompressFormat.PNG, 100, output);
但即使我将质量从100改为更低的数字,我也看不出有什么区别

if (requestCode == cameraData && resultCode == RESULT_OK
            && null != data) {
        Bitmap photo = (Bitmap) data.getExtras().get("data");

        ImageView imageView = (ImageView) findViewById(R.id.imgView);
        imageView.setImageBitmap(photo);

        // convert imageview to bitm
        imageView.buildDrawingCache();
        final Bitmap bmap = imageView.getDrawingCache();

        addIt.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                OutputStream output;

                // Find the SD Card path
                File filepath = Environment.getExternalStorageDirectory();

                // Create a new folder AndroidBegin in SD Card
                File dir = new File(filepath.getAbsolutePath()
                        + "/filepath1/");
                dir.mkdirs();

                // Create a name for the saved image
                File file = new File(dir, "image.png");

                // Notify the user on successful save
                Toast.makeText(Images.this, "Image Saved to SD Card",
                        Toast.LENGTH_SHORT).show();
                try {

                    // Image starts saving
                    output = new FileOutputStream(file);

                    // Compress into png format image from 0% - 100%, using
                    // 100% for this tutorial
                    bmap.compress(Bitmap.CompressFormat.PNG, 100, output);

                    output.flush();
                    output.close();

                    Intent myIntent = new Intent(Images.this,
                            MyPreferencesActivity.class);
                    startActivity(myIntent);
                }

                // Catch exceptions
                catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
召唤


仅返回图像的缩略图。按照本教程从相机保存图像:

PNG是无损的,“质量”设置不适用于该格式。您可以检查此答案。那很好。
Bitmap photo = (Bitmap) data.getExtras().get("data");