简体   繁体   中英

How to get a high resolution image

My problem is, when I take a picture from camera and passing to another activity. The image is not in high resolution. How can I make my image in high resolution. my codes below

Main Activity

    Button btn_cam = (Button) findViewById(R.id.btn_cam);
    btn_cam.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            MainActivity.this.startActivityForResult(intent, CAMERA_PIC_REQUEST);

        }
    });
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {

        Bitmap image = (Bitmap) data.getExtras().get("data");
        Intent cam = new Intent(this, MainCam.class);
        cam.putExtra("flostic", image);
        startActivity(cam);

Second Activity

            Intent intent = getIntent();
            imageBitmap = (Bitmap) intent.getParcelableExtra("flostic");

Add an MediaStore.EXTRA_OUTPUT to the intent,and give path in putExtra to specify path for picture saving, because otherwise it only returns a snap of picture not a high resuolution picture. Refer this doc .

Standard Intent action that can be sent to have the camera application capture an image and return it. The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT .

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