Android Camera Set Resolution

前端 未结 2 368
既然无缘
既然无缘 2020-12-14 22:29

I have built a custom Camera App and I am trying to change the resoloution of the image that is took. I have read around that this could depend on the phone or version of An

相关标签:
2条回答
  • 2020-12-14 22:48

    There is no setResolution(), only setPictureSize(). Use getSupportedPictureSizes() on Camera.Parameters to find the size you want, or use that information to populate a ListView or Spinner or something for the user to choose the desired size. Here is a sample project recently updated to use getSupportedPictureSizes() to find the smallest supported resolution and use that.

    0 讨论(0)
  • 2020-12-14 23:11

    It's too easy to capture image with high quality, here you can set your own resolution:

    mCamera = Camera.open();
    Camera.Parameters params = mCamera.getParameters();
    
    // Check what resolutions are supported by your camera
    List<Size> sizes = params.getSupportedPictureSizes();
    
    // Iterate through all available resolutions and choose one.
    // The chosen resolution will be stored in mSize.
    Size mSize;
    for (Size size : sizes) {
        Log.i(TAG, "Available resolution: "+size.width+" "+size.height);
            mSize = size;
        }
    }
    
    Log.i(TAG, "Chosen resolution: "+mSize.width+" "+mSize.height);
    params.setPictureSize(mSize.width, mSize.height);
    mCamera.setParameters(params); 
    

    Hope this will help you all.

    0 讨论(0)
提交回复
热议问题