问题
I am working on Custom Camera using Surface view in my application, also recording Video with screen Capture.
I am looking to implement Zoom Control in my Camera Code but not getting success.
Getting this log while Zooming:
E/Adreno200-ES20(12756): <qgl2DrvAPI_glBufferSubData:709>: GL_INVALID_OPERATION
I am using below code:
/** * setZoomControl * @param params */
public void setZoomControl(Camera.Parameters params) {
paramtrs = params;
ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
if (params.isZoomSupported()) {
final int maxZoomLevel = paramtrs.getMaxZoom();
Log.i("max ZOOM ", "is " + maxZoomLevel);
zoomControls.setIsZoomInEnabled(true);
zoomControls.setIsZoomOutEnabled(true);
zoomControls.setOnZoomInClickListener(new OnClickListener() {
public void onClick(View v) {
int currentZoomLevel = 0;
if (currentZoomLevel < maxZoomLevel) {
currentZoomLevel++;
camera.startSmoothZoom(currentZoomLevel);
}
}
});
zoomControls.setOnZoomOutClickListener(new OnClickListener() {
public void onClick(View v) {
int currentZoomLevel = 0;
if (currentZoomLevel > 0) {
currentZoomLevel--;
camera.startSmoothZoom(currentZoomLevel);
}
}
});
} else
zoomControls.setVisibility(View.GONE);
}
Please suggest me whats happening in my code.
回答1:
You can use this code
if (params.isZoomSupported()) {
final int maxZoomLevel = params.getMaxZoom();
Log.i("max ZOOM ", "is " + maxZoomLevel);
zoomControls.setIsZoomInEnabled(true);
zoomControls.setIsZoomOutEnabled(true);
zoomControls.setOnZoomInClickListener(new OnClickListener(){
public void onClick(View v){
if(currentZoomLevel < maxZoomLevel){
currentZoomLevel++;
//mCamera.startSmoothZoom(currentZoomLevel);
params.setZoom(currentZoomLevel);
mCamera.setParameters(params);
}
}
});
zoomControls.setOnZoomOutClickListener(new OnClickListener(){
public void onClick(View v){
if(currentZoomLevel > 0){
currentZoomLevel--;
params.setZoom(currentZoomLevel);
mCamera.setParameters(params);
}
}
});
}
else
zoomControls.setVisibility(View.GONE);
来源:https://stackoverflow.com/questions/18270222/zoom-control-in-camera-is-not-working-in-android