Get full quality picture from camera and upload?


November 2018


3.7k time


I'm trying to get my app to upload a full quality image taken from the phone camera. I have the whole upload thing working, except the only issue is that the resulting image is a really small bitmap. I would love to get the full quality image instead. Can anyone help me? Here is my code.

public class UploadActivity extends Activity {

    public final static int CAMERA_REQUEST = 1888;
    InputStream is;

    protected void onCreate(Bundle savedInstanceState) {
        Button takePicture = (Button) findViewById(;
        takePicture.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(takePictureIntent, CAMERA_REQUEST);      
        Button uploadButton = (Button) findViewById(;
        uploadButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {


    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        ImageView mImageView = (ImageView) findViewById(;
        Bundle extras = data.getExtras();
        Bitmap mImageBitmap = (Bitmap) extras.get("data");
        new fileUpload().execute(mImageBitmap);

    public class fileUpload extends AsyncTask<Object, Void, Void> {
        protected Void doInBackground(Object... param) {
            Bitmap bitmapOrg = (Bitmap) param[0];
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
            bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);
            byte[] ba = bao.toByteArray();
            String ba1=Base64.encodeBytes(ba);

            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("image",ba1));

            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost("");
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();
            } catch(Exception e){
                Log.e("log_tag", "Error in http connection "+e.toString());
            return null;

1 answers


При использовании чтения Картинки из дополнительных, вы получите уменьшенное изображение.

Вы можете найти хороший пример использования камеры здесь: