0

I'm trying to create an app where the user can take a photo using their camera and have it save to specified folder. However when it converts from the imageView to a PNG file there is a significant loss of quality.

I thought that using this bit of code would ensure the quality would remain high

bmap.compress(Bitmap.CompressFormat.PNG, 100, output);

But even when I change the quality from 100 to a lower number, I can't see any difference.

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();
                }
            }
iRushnikov
  • 27
  • 1
  • 5

1 Answers1

1

Call

Bitmap photo = (Bitmap) data.getExtras().get("data"); 

returns only thumbnail of an image. Follow this tutorial to save an image from camera: http://developer.android.com/training/camera/photobasics.html