0

i take image from gallery and camera when i upload image from camera it loss quality but gallery image is in actual quality

from camera enter image description here

from gallery enter image description here

here is my code to upload image from camera and gallery

to get image from cam

    Intent in = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
 File out = Environment.getExternalStorageDirectory();
 String fileName=GetFileName().replace('.', ' ')+".png";
 out = new File(out, fileName); 
in.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out));
 startActivityForResult(in, cameraIdNotSdCard);

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//from camera
    wb.loadUrl(sendUrl);

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

                int width = 350;
                int height = 400;
                if (HomePage.permistionArray.length > 4) {

                    width = Integer.valueOf(HomePage.permistionArray[3]);
                    height = Integer.valueOf(HomePage.permistionArray[4]);
                }

                // Log.d("ddddddddddddd", width+":"+height);

                Bitmap resizeBitmap = Bitmap.createScaledBitmap(bm, width,
                        height, true);

                    ByteArrayOutputStream boas = new ByteArrayOutputStream();
                // bm.compress(Bitmap.CompressFormat.PNG, 100, boas);

                resizeBitmap.compress(Bitmap.CompressFormat.JPEG  ,100, boas);

                byte[] b = boas.toByteArray();
                imageS = Base64.encodeToString(b, 0);

                // call custom class which class web service in background which
                // save image ..
                new imageSaveClass(getApplicationContext()).execute();

            }
        }
        // form gallery result
           if (requestCode == galleryRsultCode && resultCode == RESULT_OK
                    && data != null) {

            Uri selectedImage = data.getData();


            String[] filePathColum = { MediaStore.Images.Media.DATA };

            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColum, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColum[0]);

            String picturePath = cursor.getString(columnIndex);

            Bitmap myBitmap = BitmapFactory
                    .decodeFile(picturePath);
            if(myBitmap!=null)
            {
                int width = 350;
                int height = 400;
                if (HomePage.permistionArray.length > 4) {

                    width = Integer.valueOf(HomePage.permistionArray[3]);
                    height = Integer.valueOf(HomePage.permistionArray[4]);
                } 

                // Log.d("ddddddddddddd", width+":"+height);

                Bitmap resizeBitmap = Bitmap.createScaledBitmap(myBitmap, width,
                        height, true);

                ByteArrayOutputStream boas = new ByteArrayOutputStream();
                // bm.compress(Bitmap.CompressFormat.PNG, 100, boas);

                resizeBitmap.compress(Bitmap.CompressFormat.PNG, 100, boas);

                byte[] b = boas.toByteArray();
                imageS = Base64.encodeToString(b, 0);

                // call custom class which class web service in background which
                // save image ..
                new imageSaveClass(getApplicationContext()).execute();
            }

        }

i take image from gallery and camera when i upload image from camera it loss quality but gallery image is in actual quality

how i can improve quality from camera

Mansoor
  • 41
  • 11
  • 2
    inside onActivityResult you are getting the image for thumbnail purpose its not the actual image. http://stackoverflow.com/questions/10779789/android-not-able-to-get-original-photo-captured-by-camera-able-to-read-compres – Vivart Nov 11 '13 at 09:16
  • i use this code to get image from cam Intent in = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File out = Environment.getExternalStorageDirectory(); String fileName=GetFileName().replace('.', ' ')+".png"; out = new File(out, fileName); in.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out)); startActivityForResult(in, cameraIdNotSdCard); – Mansoor Nov 11 '13 at 11:33

1 Answers1

0

Try changing the compress format.

You are using for Camera:

 resizeBitmap.compress(Bitmap.CompressFormat.JPEG  ,100, boas);

And for Galery:

 resizeBitmap.compress(Bitmap.CompressFormat.PNG ,100, boas);

Also read this.

Community
  • 1
  • 1
Mikel
  • 1,581
  • 17
  • 35