Android Camera Zoom programming steps
- 2020-06-19 11:41:27
- OfStack
1. Add Camera permissions
2. Judge whether zoom is supported or not
public boolean isSupportZoom()
{
boolean isSuppport = true;
if (mCamera.getParameters().isSmoothZoomSupported())
{
isSuppport = false;
}
return isSuppport;
}
3. Modify the focal length
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. There is a situation that the system camera can zoom, but the custom camera cannot, which cannot be solved at present