Android Camera变焦编程步骤
1、添加Camera权限
2、判断是否支持变焦
public boolean isSupportZoom()
{
boolean isSuppport = true;
if (mCamera.getParameters().isSmoothZoomSupported())
{
isSuppport = false;
}
return isSuppport;
}
3、修改焦距
public void setZoom()
{
if (mIsSupportZoom)
{
try
{
Parameters params = mCamera.getParameters();
final int MAX = params.getMaxZoom();
if(MAX==0)return;
int zoomValue = params.getZoom();
Trace.Log("-----------------MAX:"+MAX+" params : "+zoomValue);
zoomValue += 5;
params.setZoom(zoomValue);
mCamera.setParameters(params);
Trace.Log("Is support Zoom " + params.isZoomSupported());
}
catch (Exception e)
{
Trace.Log("--------exception zoom");
e.printStackTrace();
}
}
else
{
Trace.Log("--------the phone not support zoom");
}
}
4、存在系统相机可以变焦,自定义相机不可以的情况,目前无法解决