1

I am trying to implement an app that will use camera to capture an image and display it on the ImageView. However, the system will resize the pic resolution to 204x153 before it display on the screen, but it save the original resolution (3264x2448) of the image in sd card.

this is my code.

buttonCapture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent intentCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            bmpUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),  
                    "pic_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));  
            try {  
                intentCamera.putExtra("return-data", false);  
                startActivityForResult(intentCamera, resultOpenCamera);  
            } 
            catch (ActivityNotFoundException e) {  
                e.printStackTrace();  
            }               
        }
    });

and my onActivityResult

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (requestCode == resultOpenCamera && resultCode == RESULT_OK && null != data) {
            setContentView(R.layout.preview);

            if(data.getAction() != null){  

               Uri selectedImage = data.getData();
               bmpUri = selectedImage;
               // display image received on the view
               Bundle newBundle = data.getExtras();
               Bitmap theImage = (Bitmap) newBundle.get("data");
               displayImage(preProcessing(theImage));  
               System.out.println("theImage height n width = "+theImage.getHeight()+" + "+theImage.getWidth());
            }
        }
}

I have use System.out.println to trace the bitmap resolution that capture from the camera. it show that only have 204x153. The original resolution should be 3264x2448.

Anyone know how to solve this?? Thanks a lot.

Ridcully
  • 23,362
  • 7
  • 71
  • 86
Yeehoong Lim
  • 41
  • 1
  • 5
  • Please refer this question. Its similar to this one. http://stackoverflow.com/questions/5991319/capture-image-from-camera-and-display-in-activity – Scorpion Oct 17 '12 at 10:54

3 Answers3

2

Just from official documentation of ACTION_IMAGE_CAPTURE:

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.

ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53
0

Try to set the scale type of the imageview to center or centerInside.

RSai
  • 51
  • 6
  • yup, i tried this. but it is depends on the size of image itself, the image loaded from the camera will be automatically scale down, so is still will show the scale down image instead of full image. – Yeehoong Lim Oct 26 '12 at 15:46
0

Try This :-

int width = bmpSelectedImage.getWidth();
int height = bmpSelectedImage.getHeight();
float scaleWidth = ((float) 250) / width;
float scaleHeight = ((float) 150) / height;
Matrix matrix = new Matrix(); matrix.postRotate(90);
resizedBitmap = Bitmap.createBitmap(bmpSelectedImage, 0, 0, width, height, matrix, true);
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
Deepanker Chaudhary
  • 1,694
  • 3
  • 15
  • 35