kumar piyush
kumar piyush

Reputation: 173

Setting resolution of the image taken by a camera

In my application, I am taking an image through the inbuilt camera activity and storing it in the SD card. I am using intent.putextras to get a high resoltuion image.

1st device- The code works successfully and I get an image of resolution of 640X480.

2nd device- When the built in camera activity asks for saving the image captured, it force closes. But when i explicitly change the device's camera resolution to 640X480 and re-run the application, it works perfectly fine.

Questions:-

  1. Methods to overcome this ??
  2. Can this be an android version related problem. The android version of the two devices is different.
  3. Is thera a way of passing the resolution parameters(640,480) to the built in camera activity?? Or a self made camera activity is necessary??

Here goes the code

public void onClick(View v) {
    // TODO Auto-generated method stub

    if(v.getId()!=1000){
        imageFile = "bmp"+v.getId()+".png";

        File f = new File (folder,imageFile);
         imageUri = Uri.fromFile(f);
        Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageUri);
        startActivityForResult(i,CAMERA_PIC_REQUEST);   
    }
    if(v.getId()==1000){
        Intent openFinalShow = new Intent("com.integrated.mpr.FINALSHOW");
        startActivity(openFinalShow);
        finish();
    }

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub

    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == RESULT_OK){
            return;
    }
}

Upvotes: 1

Views: 3248

Answers (2)

type-a1pha
type-a1pha

Reputation: 1893

Either the intent lets you specify the resolution or otherwie you cannot achieve what you want. Moreover you got to be sure that when setting your picture size through the Camera.Parameters object you only use one from the values given by Camera.getSupportedPitureSizes.

Upvotes: 0

D Yao.
D Yao.

Reputation: 401

I do not believe it is possible to pass in resolution parameters with the intent to the stock camera. There are issues here with regards to different phones having different cameras, as well as with the potential for the user to have a different default camera application which would not recognize said intent extras.

The solution to your problem is to write a custom camera activity, with your own preview and camera settings. Then you can properly set the resolution of the recorded images/video. as well as the resolution and/or size of the preview window, etc.

The camera developer guide and other searches for custom android camera examples will be of use

Upvotes: 1

Related Questions