代码片段用于设置相机参数,如下所示:
lockRun(new Runnable() {
@Override
public void run() {
Log.v("jerikc","applyParameters before width="+getParameters().getPictureSize().width+",height="+getParameters().getPictureSize());
//preview size changed, zsd changed, camera mode changed, open camera.
mSettingChecker.applyPreferenceToParameters();
Log.v("jerikc","applyParameters after width="+getParameters().getPictureSize().width+",height="+getParameters().getPictureSize());
}
});
SettingChecker.java
public void applyPreferenceToParameters() {
Log.v("jerikc","SettingChecker.applyPreferenceToParameters before width="+mContext.getParameters().getPictureSize().width+",height="+mContext.getParameters().getPictureSize());
...
Log.v("jerikc","SettingChecker.applyPreferenceToParameters after width="+mContext.getParameters().getPictureSize().width+",height="+mContext.getParameters().getPictureSize());
}
日志如下:
V/jerikc (17866): applyParameters before width=2560,height=android.hardware.Camera$Size@4fde180
V/jerikc (17866): SettingChecker.applyPreferenceToParameters before width=2560,height=android.hardware.Camera$Size@4fde180
V/jerikc (17866): SettingChecker.applyPreferenceToParameters after width=4096,height=android.hardware.Camera$Size@7fc9900
V/jerikc (17866): applyParameters after width=2560,height=android.hardware.Camera$Size@4fde180
我在调用mSettingChecker.applyPreferenceToParameters()之前和结束时都添加了日志 。我还在方法applyPreferenceToParameters之前和结尾添加了日志。getParameters()将 返回mParameter对象。
为什么宽度的值不同(一个是 4096,另一个是 2560)?