简体   繁体   中英

How to send the image taken with device camera as it is to server without losing its quality, width and height?

I am taking the picture and saving it in sdcard. And later some time I am saving the same picture to server by creating a file like the following.

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

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

            byte[] b = boas.toByteArray();

The Byte array I am sending to the server.

But image quality and size is saving incorrect. If the resolution is 1200 X 1600 instead 320 * 240 is saving in server.

How are you saving your picture when it is taken? If you don't supply a URI you will only get a low resolution thumbnail in return.

EDIT: Code how to get full image from camera, I'm only guessing your problem right now;

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

从您发布的代码中,它仅显示您从位图制作一个PNG,然后制作质量下降0%的JPG。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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