本文整理了Java中android.hardware.Camera.getParameters()
方法的一些代码示例,展示了Camera.getParameters()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.getParameters()
方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:getParameters
暂无
代码示例来源:origin: stackoverflow.com
Camera cam = Camera.open();
Parameters p = cam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(p);
cam.startPreview();
代码示例来源:origin: vondear/RxTool
@Override
public void onAutoFocus(boolean success, Camera camera) {
Camera.Parameters params = camera.getParameters();
params.setFocusMode(currentFocusMode);
camera.setParameters(params);
}
});
代码示例来源:origin: stackoverflow.com
Camera.Size previewSize = mCamera.getParameters().getPreviewSize();
setLayoutParams(new FrameLayout.LayoutParams(
previewSize.width, previewSize.height, Gravity.CENTER));
} catch (IOException t) {}
mCamera.startPreview();
this.setVisibility(INVISIBLE); // Make the surface invisible as soon as it is created
代码示例来源:origin: stackoverflow.com
SurfaceView preview = (SurfaceView) findViewById(R.id.PREVIEW);
SurfaceHolder mHolder = preview.getHolder();
mHolder.addCallback(this);
Camera mCamera = Camera.open();
mCamera.setPreviewDisplay(mHolder);
// Turn on LED
Parameters params = mCamera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(params);
mCamera.startPreview();
...
// Turn off LED
Parameters params = mCamera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_OFF);
mCamera.setParameters(params);
mCamera.stopPreview();
mCamera.release();
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
void setTorch(Camera camera, boolean newSetting) {
Camera.Parameters parameters = camera.getParameters();
doSetTorch(parameters, newSetting, false);
camera.setParameters(parameters);
}
代码示例来源:origin: stackoverflow.com
mCamera = Camera.open();
Camera.Size previewSize = mCamera.getParameters().getPreviewSize();
mTextureView.setLayoutParams(new FrameLayout.LayoutParams(
previewSize.width, previewSize.height, Gravity.CENTER));
mCamera.startPreview();
代码示例来源:origin: vondear/RxTool
/**
* 打开闪光灯
*
* @return
*/
public static void openFlashLight() {
try {
if (camera == null) {
camera = Camera.open();
camera.startPreview();
}
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: rmtheis/android-ocr
void setTorch(Camera camera, boolean newSetting) {
Camera.Parameters parameters = camera.getParameters();
doSetTorch(parameters, newSetting);
camera.setParameters(parameters);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean currentSetting = prefs.getBoolean(PreferencesActivity.KEY_TOGGLE_LIGHT, false);
if (currentSetting != newSetting) {
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(PreferencesActivity.KEY_TOGGLE_LIGHT, newSetting);
editor.commit();
}
}
代码示例来源:origin: doggycoder/AndroidOpenGLDemo
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
mCamera = Camera.open(cameraId);
mController.setImageDirection(cameraId);
Camera.Size size = mCamera.getParameters().getPreviewSize();
mController.setDataSize(size.height, size.width);
try {
mCamera.setPreviewTexture(mController.getTexture());
mController.getTexture().setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
mController.requestRender();
}
});
} catch (IOException e) {
e.printStackTrace();
}
mCamera.startPreview();
}
代码示例来源:origin: stackoverflow.com
Camera cam;
void ledon() {
cam = Camera.open();
Parameters params = cam.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_ON);
cam.setParameters(params);
cam.startPreview();
cam.autoFocus(new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
}
});
}
void ledoff() {
cam.stopPreview();
cam.release();
}
代码示例来源:origin: vondear/RxTool
/**
* 关闭闪光灯
*
* @return
*/
public static void closeFlashLight() {
try {
if (camera == null) {
} else {
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.release();
camera = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: gqjjqg/android-extend
public boolean startPreview() {
Size imageSize = mCamera.getParameters().getPreviewSize();
int lineBytes = imageSize.width * ImageFormat.getBitsPerPixel(mCamera.getParameters().getPreviewFormat()) / 8;
mCamera.setPreviewCallbackWithBuffer(this);
mCamera.addCallbackBuffer(new byte[lineBytes * imageSize.height]);
mCamera.addCallbackBuffer(new byte[lineBytes * imageSize.height]);
mCamera.addCallbackBuffer(new byte[lineBytes * imageSize.height]);
mCamera.startPreview();
return true;
}
代码示例来源:origin: stackoverflow.com
mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
for(Camera.Size str: mSupportedPreviewSizes)
Log.e(TAG, str.width + "/" + str.height);
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
mCamera.setParameters(parameters);
mCamera.setDisplayOrientation(90);
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
代码示例来源:origin: journeyapps/zxing-android-embedded
/**
* Changes the settings for Camera.
*
* @param callback {@link CameraParametersCallback}
*/
public void changeCameraParameters(CameraParametersCallback callback) {
if (camera != null) {
try {
camera.setParameters(callback.changeCameraParameters(camera.getParameters()));
} catch(RuntimeException e) {
// Camera error. Could happen if the camera is being closed.
Log.e(TAG, "Failed to change camera parameters", e);
}
}
}
代码示例来源:origin: stackoverflow.com
} else {
Parameters param = camera.getParameters();
param.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
try {
camera.setParameters(param);
camera.startPreview();
isLightOn = true;
} catch (Exception e) {
代码示例来源:origin: dm77/barcodescanner
public void setupCameraParameters() {
Camera.Size optimalSize = getOptimalPreviewSize();
Camera.Parameters parameters = mCameraWrapper.mCamera.getParameters();
parameters.setPreviewSize(optimalSize.width, optimalSize.height);
mCameraWrapper.mCamera.setParameters(parameters);
adjustViewSize(optimalSize);
}
代码示例来源:origin: daniulive/SmarterStreaming
parameters = mCamera.getParameters();
} catch (Exception e) {
mCamera.setParameters(parameters);
mCamera.startPreview();
mCamera.autoFocus(myAutoFocusCallback);
mPreviewRunning = true;
代码示例来源:origin: TommyLemon/APIJSON
/**开关闪光灯
* @param open
* @return
*/
public boolean switchLight(boolean open) {
parameter = camera.getParameters();
if (open) {
parameter.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameter);
return true;
} else {
parameter.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(parameter);
return false;
}
}
//Lemon add >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
代码示例来源:origin: daniulive/SmarterStreaming
parameters = pushCamera.getParameters();
} catch (Exception e) {
pushCamera.setParameters(parameters);
pushCamera.startPreview();
pushCamera.autoFocus(pushAutoFocusCallback);
pushPreviewRunning = true;
代码示例来源:origin: LaiFeng-Android/SopCastComponent
public static void setTouchFocusMode(Camera camera) {
try {
Camera.Parameters parameters = camera.getParameters();
List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.size() > 0 && focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
camera.setParameters(parameters);
} else if (focusModes.size() > 0) {
parameters.setFocusMode(focusModes.get(0));
camera.setParameters(parameters);
}
} catch (Exception e) {
e.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!