[DESCRIPTION]
修改默认拍照size
[SOLUTION]
修改默认的capture size,改变camera feature table的FID_CAP_SIZE default值不起作用。 因为camera AP并没有从feature table读取FID_CAP_SIZE的default值。
下面介绍在AP端修改默认的capture size,分为在初始化时候和restore时候修改。以默认capture size 1600x1200为例。
修改文件:Camera.java (alpspackagesappscamerasrccomandroidcamera)。
1、在AP初始化设置参数的时候修改默认的capture size。
private void updateCameraParametersPreference()方法中,将
if (pictureSize == null) {
CameraSettings.initialCameraPictureSize(this, mParameters, camOri);
} else {
List<Size> supported = mParameters.getSupportedPictureSizes();
CameraSettings.setCameraPictureSize(pictureSize, supported,
mParameters, camOri);
}
改为:
if (pictureSize == null) {
List<Size> supported = mParameters.getSupportedPictureSizes();
if(!(CameraSettings.setCameraPictureSize("1600x1200", supported,
mParameters, camOri)))
{
CameraSettings.initialCameraPictureSize(this, mParameters, camOri);
}
else
{
SharedPreferences.Editor editor = ComboPreferences
.get(this).edit();
editor.putString(CameraSettings.KEY_PICTURE_SIZE, "1600x1200");
editor.apply();
}
} else {
List<Size> supported = mParameters.getSupportedPictureSizes();
CameraSettings.setCameraPictureSize(pictureSize, supported,
mParameters, camOri);
}
2、恢复默认参数的时候,需要添加默认的capture size。
private void restorePreferences()方法中,
在CameraSettings.restorePreferences(Camera.this, mPreferences,mParameters);
之后添加:
List<Size> supported = mParameters.getSupportedPictureSizes();
int camOri = CameraHolder.instance().getCameraInfo()[mCameraId].orientation;
if (LOGI) Log.i(TAG, "supported="+supported+",camOri="+camOri);
if(camOri!=-1&&supported!=null)
{
if (LOGI) Log.i(TAG, "setCameraPictureSize=");
if(CameraSettings.setCameraPictureSize("1600x1200", supported,mParameters, camOri))
{
SharedPreferences.Editor editor = ComboPreferences
.get(this).edit();
editor.putString(CameraSettings.KEY_PICTURE_SIZE, "1600x1200");
editor.apply();
}
}
另外,对于前后摄像头不同要求,根据需要进行判断。
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
if(info.facing == CameraInfo.CAMERA_FACING_FRONT){
//sub sensor
}else{
//main sensor
}